Req #71981 [NEW]: About the static variable in static method of object

From: Date: Thu, 07 Apr 2016 07:22:53 +0000
Subject: Req #71981 [NEW]: About the static variable in static method of object
Groups: php.standards 
Request: Send a blank email to standards-+get-1067@lists.php.net to get a copy of this message
From: 1783946138 at qq dot com Operating system: win32 PHP version: 5.5.34 Package: PHP Language Specification Bug Type: Feature/Change Request Bug description:About the static variable in static method of object Description: ------------ I think the non-static method of class should be have independence in different object of this class. For example,The static variable what is in the non-static method of class should not be shared in different object. Test script: --------------- class Test { public function print_index() { static $index=0;//the static* return $index++; } } $obj1=new Test; $obj2=new Test; //I think there should be echo $obj1->print_index().PHP_EOL;//result:0 0 echo $obj2->print_index().PHP_EOL;//result:1 0 echo $obj1->print_index().PHP_EOL;//result:2 1 echo $obj2->print_index().PHP_EOL;//result:3 1 Expected result: ---------------- 0 0 1 1 Actual result: -------------- 0 1 2 3 -- Edit bug report at https://bugs.php.net/bug.php?id=71981&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71981&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71981&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71981&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71981&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71981&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71981&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71981&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71981&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71981&r=support Expected behavior: https://bugs.php.net/fix.php?id=71981&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71981&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71981&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71981&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71981&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71981&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71981&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71981&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71981&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71981&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71981&r=mysqlcfg

« previous php.standards (#1067) next »