|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-09-10 17:19 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 23 21:00:01 2025 UTC |
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=