Last active
August 21, 2019 09:22
-
-
Save MarceauKa/21216e47d643daeed0c58954db70e3cf to your computer and use it in GitHub Desktop.
Test empty on PHP magic properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
public function __get($name) | |
{ | |
return 'foo'; | |
} | |
} | |
class Bar | |
{ | |
public function __get($name) | |
{ | |
return 'bar'; | |
} | |
public function __isset($name) | |
{ | |
return true; | |
} | |
} | |
$foo = new Foo(); | |
$bar = new Bar(); | |
var_dump($foo->foo, empty($foo->foo)); | |
// => foo, true | |
var_dump($bar->bar, empty($bar->bar)); | |
// => bar, false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment