note 88715 added to function.array-pop

From: Date: Wed, 04 Feb 2009 17:18:34 +0000
Subject: note 88715 added to function.array-pop
Groups: php.notes 
Request: Send a blank email to php-notes+get-150207@lists.php.net to get a copy of this message
Beware that array_pop() returns a copy of the element (even if the array element is a reference). That means you will get different results on PHP 4 and 5 when dealing with objects. <?php $a = new stdClass(); $a->foo = 'bar'; $arr = array(&$a); $b = array_pop($arr); $b->foo = 'baz'; var_dump($a); ?> Output of PHP 5.2.8: object(stdClass)#1 (1) { ["foo"]=> string(3) "baz" } Output of PHP 4.4.9: object(stdClass)(1) { ["foo"]=> string(3) "bar" } For more information please refer to: http://br2.php.net/manual/en/language.oop5.references.php ---- Server IP: 200.185.126.110 Probable Submitter: 201.7.114.248 ---- Manual Page -- http://www.php.net/manual/en/function.array-pop.php Edit -- https://master.php.net/note/edit/88715 Del: integrated -- https://master.php.net/note/delete/88715/integrated Del: useless -- https://master.php.net/note/delete/88715/useless Del: bad code -- https://master.php.net/note/delete/88715/bad+code Del: spam -- https://master.php.net/note/delete/88715/spam Del: non-english -- https://master.php.net/note/delete/88715/non-english Del: in docs -- https://master.php.net/note/delete/88715/in+docs Del: other reasons-- https://master.php.net/note/delete/88715 Reject -- https://master.php.net/note/reject/88715 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150207) next »