|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-10-29 17:02 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 15:00:01 2025 UTC |
If a child class has a __construct() function, it won't make use of its parent's __get() function (and presumably other overload functions too). Workaround: add a __get() to the child class and call parent::__get($property). test code: <?php class a { function __get() { return 'a::_get'; } } class b extends a { } class c extends a { function __construct() { } } class d extends a { function __construct() { } function __get($p) { return parent::__get($p); } } $a = new a; print "a->foo = {$a->foo}\n"; $b = new b; print "b->foo = {$b->foo}\n"; $c = new c; print "c->foo = {$c->foo}\n"; $d = new d; print "d->foo = {$d->foo}\n"; ?> output: PHP Notice: Undefined property: foo in /full/path/overload.php on line 11 overload.php(11) : Notice - Undefined property: foo a->foo = a::_get b->foo = a::_get Notice: Undefined property: foo in /full/path/overload.php on line 11 c->foo = d->foo = a::_get