Arquivos
hhvm/hphp/test/vm/clone.php
T
Jordan Delong 363d1bb20f Code move src/ -> hphp/
This change is mostly for FB internal organizational reasons.
Building is not effected beyond the fact that the target now
lands in hphp/hhvm/hhvm rather than src/hhvm/hhvm.
2013-02-11 02:10:41 -08:00

36 linhas
525 B
PHP

<?php
class A {
public $x;
static $count = 0;
public function __construct() {
$this->x = ++self::$count;
}
public function __clone() {
$this->x = ++self::$count;
}
};
function main() {
$a = new A;
$a->y = "foo";
$b = clone $a;
$a->y = "bar";
var_dump($b);
class C {}
$ten = 10;
$d = new C();
$d->thing = &$ten;
unset($ten); // now the property is the only reference
var_dump($d);
$e = clone $d;
var_dump($d); // the reference doesn't persist across the clone
}
main();