|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-30 11:58 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 23:00:01 2025 UTC |
Description: ------------ The magic overloading function __get() can't seem to access inherited, non-visible properties. If you overload with __get() in a base class, then extend that class, the base class's __get() will return NULL when accessing an inaccessible property of the child class. The __get() function doesn't even see the property as being set (if you run an isset($name) in the __get() call, it returns false. Reproduce code: --------------- class testParent { function __get($name){ return $this->$name; } } class testChild extends testParent { private $testVar = 'Bar'; } $t = new testChild; echo 'Foo: ' . $t->testVar; Expected result: ---------------- You would expect the code to output 'Foo: Bar'. instead, it outputs 'Foo:', because the __get() in testParent apparently can't see the private vars in testChild. Actual result: -------------- Output's 'Foo:', withOUT the 'Bar'