Arquivos
hhvm/hphp/test/quick/clone.php
T
ptarjan 503f75d08b Rename test directories
These names don't make sense now that we run both suites the same
way.
2013-04-17 09:06:51 -07: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();