#34448 [NEW]: Global variables inside of a method of a class are not initialized

From: Date: Fri, 09 Sep 2005 19:07:57 +0000
Subject: #34448 [NEW]: Global variables inside of a method of a class are not initialized
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-84810@lists.php.net to get a copy of this message
From: diplex19 at yandex dot ru Operating system: Windows PHP version: 5.0.5 PHP Bug Type: Scripting Engine problem Bug description: Global variables inside of a method of a class are not initialized Description: ------------ Global variables inside of a method of a class are not initialized Reproduce code: --------------- <? class test1 { var $my_var; function init($str) { $this->my_var=$str; return $this->my_var; } } class bug_test { function set_var($str) { global $info; $info=&new test1(); return $info->init($str); } function get_var() { global $info; return $info->my_var; } } global $info; $t=&new bug_test(); $f0=$t->set_var('menu1'); $f1=$t->get_var(); $f2=$t->set_var('menu2'); $f3=$t->get_var(); echo "f0=$f0\nf1=$f1\nf2=$f2\nf3=$f3\n"; // php-bug! f1<>'menu1' & f3<>'menu2 ?> Expected result: ---------------- f0=menu1 f1=menu1 f2=menu2 f3=menu2 Actual result: -------------- f0=menu1 f1= f2=menu2 f3= -- Edit bug report at http://bugs.php.net/?id=34448&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34448&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34448&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34448&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34448&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34448&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34448&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34448&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34448&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34448&r=support Expected behavior: http://bugs.php.net/fix.php?id=34448&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34448&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34448&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34448&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34448&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34448&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34448&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34448&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34448&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34448&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34448&r=mysqlcfg

« previous php.bugs (#84810) next »