|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-03 21:52 UTC] tony2001@php.net
[2005-02-05 05:41 UTC] e at narod dot ru
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 24 14:00:02 2025 UTC |
Description: ------------ Function array_shift() modifies array passed by value from class method. In the example below $_cache is modified through array_shift() call though $_cache is always passed by value. The bug doesn't appear if we don't use classes. Reproduce code: --------------- class A { var $_cache = false; function get_array() { if (!$this->_cache) $this->_cache = array(1, 2, 3, 4, 5); return $this->_cache; } function get_shifted_array() { return array_shift($this->get_array()); } } $a = new A; for ($i = 0; $i < 5; $i++) echo $a->get_shifted_array() . "\n"; Expected result: ---------------- 1 1 1 1 1 Actual result: -------------- 1 2 3 4 5