ID:               31762
 Updated by:       [EMAIL PROTECTED]
 Reported By:      e at narod dot ru
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP
 PHP Version:      5.0.3
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

That's how it works.
See http://php.net/array_shift


Previous Comments:
------------------------------------------------------------------------

[2005-01-30 05:38:14] e at narod dot ru

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



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31762&edit=1

Reply via email to