Bug #67332 [Opn->Nab]: The local static variables

From: Date: Fri, 23 May 2014 08:16:58 +0000
Subject: Bug #67332 [Opn->Nab]: The local static variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185909@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67332&edit=1 ID: 67332 Updated by: johannes@php.net Reported by: dreamsxin at qq dot com Summary: The local static variables -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Ubuntu PHP Version: 5.4.28 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 The method is still the same in both cases. If you need object-specific state use a property. If you truly (I'd question your design) class hierarchy-specific static state you can do something using late static binding and i.e. an static array ... Previous Comments: ------------------------------------------------------------------------ [2014-05-23 07:41:24] dreamsxin at qq dot com Description: ------------ Local static variables, in the parent and child classes, is the same. In 5.5.7 has same proplem. https://bugs.php.net/bug.php?id=53155 Test script: --------------- <?php class Test { public static function hello() { static $my; if ($my) { $my = '2'; } else { $my = '1'; } var_dump($my); } } class Test2 extends Test { } Test::hello(); Test::hello(); Test2::hello(); Expected result: ---------------- string(1) "1" string(1) "2" string(1) "2" Actual result: -------------- string(1) "1" string(1) "2" string(1) "1" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67332&edit=1

« previous php.bugs (#185909) next »