Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_execute.c zend_language_parser.y

From: Date: Thu, 24 Jul 2003 17:14:28 +0000
Subject: Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_execute.c zend_language_parser.y
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-3592@lists.php.net to get a copy of this message
At 19:12 24/07/2003, Sebastian Bergmann wrote:
Zeev Suraski wrote: A copy, yes. Why? I thought the Zend Engine 2's new Object Model passed worked with references by default and only uses copies when "asked".
This has nothing to do with the new object model. That's why I used the word 'copy', which is generic to any PHP value, and not 'clone', which has object oriented associations... You could use foreach() in PHP 5 to change the objects themselves (you get that out of the box with the new object model), but you couldn't, for instance, replace the elements in the array with other objects or elements. Look at the test attached below. Zeev <?php $arr = array(1 => "one", 2 => "two", 3 => "three"); foreach($arr as $key => $val) {
    $val = $key;
} print_r($arr); foreach($arr as $key => &$val) {
    $val = $key;
} print_r($arr); ?> ---- Expected results: Array (
    [1] => one
    [2] => two
    [3] => three
) Array (
    [1] => 1
    [2] => 2
    [3] => 3
)

« previous php.internals (#3592) next »