#18842 [NEW]: 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:16:00 +0000 |
| Subject: | #18842 [NEW]: cloning functions improperly, creates references and not copies | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-16421@lists.php.net to get a copy of this message | ||
From: ben-bugs.php.net@efros.com
Operating system: linux
PHP version: 4CVS-2002-08-10
PHP Bug Type: Zend Engine 2 problem
Bug description: cloning functions improperly, creates references and not copies
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 bug report at http://bugs.php.net/?id=18842&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18842&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18842&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18842&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18842&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18842&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18842&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18842&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18842&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18842&r=globals