note 118851 deleted from mysqli-result.fetch-array by cmb

From: Date: Wed, 17 Feb 2016 10:23:39 +0000
Subject: note 118851 deleted from mysqli-result.fetch-array by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-204964@lists.php.net to get a copy of this message
Note Submitter: object-array at gmail dot com ---- Please mind the difference between objects and arrays in PHP>=5: arrays are by value while objects are by reference. <? $o = mysqli_fetch_object($res); $o1 = $o; $o1->value = 10; $a = mysqli_fetch_array($res); $a1 = $a; $a1['value'] = 10; echo $o->value; // 10 echo $a['value']; // (original value from db) ?> Should same behaviour be intended, the object needs to be cloned: <? $o1 = clone $o; ?> More about object cloning: http://php.net/manual/en/language.oop5.cloning.php

« previous php.notes (#204964) next »