Edit report at https://bugs.php.net/bug.php?id=55839&edit=1
ID: 55839 Updated by: johan...@php.net Reported by: chris at mcfadyen dot ca Summary: Static accessors through variables only work on simple variables -Status: Open +Status: Bogus Type: Bug Package: Class/Object related Operating System: Windows PHP Version: 5.3SVN-2011-10-03 (SVN) Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Variable names are case-sensitive. $B is not the same as $b. ${$a->referrer}::foo(); in your case is the same as $B::foo()m not $b::foo(); Previous Comments: ------------------------------------------------------------------------ [2011-10-03 18:47:14] chris at mcfadyen dot ca Description: ------------ Using a static operator ( :: ) works for simple variables ( $foo::function() ), but results in an undefined variable warning for the class name at run-time when using a class property ( ${$bar->foo}::function() ). Obviously, a direct access attempt ( $bar->foo::function() ) fails with a parse error. --- >From manual page: http://www.php.net/language.oop5.static --- Test script: --------------- class A { public $referrer = 'B'; } class B { public static function foo() { echo "Foo"; } } $b = 'B'; $a = new A(); $b::foo(); ${$a->referrer}::foo(); $c = $a->referrer; $c::foo(); Expected result: ---------------- I would expect to see Foo Foo Foo Actual result: -------------- This is the result: Foo Notice (8): Undefined variable: B Foo ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55839&edit=1