note 88715 deleted from function.array-pop by crell

From: Date: Tue, 12 Apr 2022 01:08:13 +0000
Subject: note 88715 deleted from function.array-pop by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218210@lists.php.net to get a copy of this message
Note Submitter: Igor Feghali ---- 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

« previous php.notes (#218210) next »