note 93812 deleted from language.references by cmb

From: Date: Sun, 01 Sep 2019 07:50:59 +0000
Subject: note 93812 deleted from language.references by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212070@lists.php.net to get a copy of this message
Note Submitter: strata_ranger at hotmail dot com ---- Note that in PHP5 you generally don't need the reference operator -- at all -- when dealing with class objects, because PHP5 implements objects using Instances (which are more like C pointers than PHP's references system). For example: <?php // // Since PHP 5 // $foo = new stdClass(); // $bar and $foo are still holding the same (single) object $bar = $foo; var_dump($foo, $bar) // object(stdClass)#1 (0) { } // object(stdClass)#1 (0) { } $bar->member = "Something"; var_dump($foo, $bar); // object(stdClass)#1 (1) { // ["member"]=> // string(9) "Something" // } // object(stdClass)#1 (1) { // ["member"]=> // string(9) "Something" // } // Use the 'clone' keyword to make a separate copy of the object $bar = clone $foo; $bar->member = "Something"; var_dump($foo, $bar); // object(stdClass)#1 (0) { } // object(stdClass)#2 (1) { // ["member"]=> // string(9) "Something" // } ?>

« previous php.notes (#212070) next »