|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-21 15:32 UTC] tony2001@php.net
[2005-07-21 15:54 UTC] pascal dot parietti at fh-aargau dot ch
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 22:00:01 2025 UTC |
Description: ------------ A static function in the base class (A) can execute a protected function in a derived class (B). If the same function is called from outside of class A the PHP Fatal error occurs as excepted. The error also occurs with the CVS Snapshot php5-STABLE-200507211237 compiled with ./configure && make Reproduce code: --------------- <?php class A { public static function test() { $a = new B(); $a->test2(); # why does this work? } } class B extends A { protected function test2() { echo "B: test2 \n"; } } A::test(); $b = new B(); # call a protected function -> PHP Fatal error as excepted: $b->test2(); ?> Expected result: ---------------- PHP Fatal error: Call to protected method B::test2() on line 5