Re: Is this a bug?!!! I cna't believe! Sorry, if im wrong...

From: Date: Mon, 31 Jan 2005 11:57:10 +0000
Subject: Re: Is this a bug?!!! I cna't believe! Sorry, if im wrong...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-207743@lists.php.net to get a copy of this message
В сообщении от Воскресенье 30 Январь 2005 16:07 news.php.net написал(a): > <? > > class A > { > var $name; > function A($str) > { > $this->name = $str; > } > } > > $arr = array(); > > //Put to array to objects of class A, > // where their attribute A::a is assigned a different value > //objects are assigned to an array by reference > > $a = &new A("qaz"); > $arr[0] = &$a; > > $a = &new A("wsx"); > $arr[1] = &$a; > > > //But watch the output!!! > // It is "(qaz)(qaz)", which means that the attribute of a first > // object assigned to array is outputted!!! WHY?!?!!! > foreach($arr as $a) > { > echo "(".$a->name.")"; > } > ?>

« previous php.general (#207743) next »