#18842 [Opn]: cloning functions improperly, creates references and not copies
| From: | ben-bugs dot php dot net at efros dot com | Date: | Sat, 10 Aug 2002 06:21:50 +0000 |
| Subject: | #18842 [Opn]: cloning functions improperly, creates references and not copies | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-16422@lists.php.net to get a copy of this message | ||
ID: 18842
User updated by: ben-bugs.php.net@efros.com
Reported By: ben-bugs.php.net@efros.com
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: linux
PHP Version: 4CVS-2002-08-10
New Comment:
I guess that if I explicitly call __clone(), everything goes okay. I
guess the problem is that it thinks I mean make reference when using
the "equals" assignment .... ?
Previous Comments:
------------------------------------------------------------------------
[2002-08-10 02:15:59] ben-bugs.php.net@efros.com
class tmp {
var $tmp = '';
function __construct($t) {
$this->tmp=$t;
}
}
$x = new tmp(4);
$y = $x;
echo "x = ".$x->tmp."<BR>\n"; /* prints 4 */
echo "y = ".(++$y->tmp)."<BR>\n"; /* prints 5 */
echo "x = ".$x->tmp."<BR>\n"; /* prints 5, but should be 4 still */
I guess the $y is still referencing the $x class ...
Also, if I create __clone(), it doesn't appear to execute.
This was tested on CVS 2002-8-8 SAPI and also 4.3.0 alpha 2 CLI
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18842&edit=1