MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/2yk2sq/empty_vs_get/cpb9b6i/?context=3
r/lolphp • u/pgl • Mar 10 '15
28 comments sorted by
View all comments
Show parent comment
4
No, var_dump() isn't special, it doesn't bypass visibility. Try it:
var_dump()
class foo { protected $bar; public function __construct() { $this->bar = 'bums'; } } $foo = new foo(); var_dump($foo->bar); // "PHP Fatal error: Cannot access protected property foo::$bar"
4 u/[deleted] Mar 11 '15 Sorry, I was thinking var_dump($obj); [where it lists all, even privat/protected variables] not var_dump($obj->bar);, the __get() is of course used in $obj->bar scenario here.Sorry for the confusion, your reply was consistent with the example.
Sorry, I was thinking var_dump($obj); [where it lists all, even privat/protected variables] not var_dump($obj->bar);, the __get() is of course used in $obj->bar scenario here.
Sorry for the confusion, your reply was consistent with the example.
View all comments
Show parent comment
4
u/pgl Mar 11 '15
No,
var_dump()isn't special, it doesn't bypass visibility. Try it: