ID:               30978
 Updated by:       [EMAIL PROTECTED]
 Reported By:      btb_tp at yahoo dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: Windows XP SP2
 PHP Version:      5.0.2
 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

What Levi said.


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

[2004-12-17 03:15:29] levi at alliancesoftware dot com dot au

This is not a bug, this a result of the new object model in PHP 5. See
http://www.zend.com/php5/articles/engine2-php-oo.php

 In PHP 4, the assignment to an object would create a new copy of that
object.

 In PHP 5, assignment to an object merely sets a *reference* to that
object, not a copy.

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

[2004-12-03 19:14:01] btb_tp at yahoo dot com

Description:
------------
Below code work with PHP 4.3.9!!!

Reproduce code:
---------------
class A{
        protected $value = 0;
        function A($value){
                $this->value = $value;}
        function getValue(){
                return $this->value;}
        function setValue($value){
                $this->value = $value;}
}

$b = array();
$a = new A(0);
for($i = 1; $i <= 2; $i++){
        $a->setValue($i);
        $b[] = $a;}
print_r($b);

Expected result:
----------------
Array ( [0] => A Object ( [value:protected] => 1 ) [1] => A Object (
[value:protected] => 2 ) ) 

Actual result:
--------------
Array ( [0] => A Object ( [value:protected] => 2 ) [1] => A Object (
[value:protected] => 2 ) ) 


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


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

Reply via email to