3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SubObject { static $instances = 0; public $instance; public function __construct() { $this->instance = ++self::$instances; } } class MyCloneable { public $object1; public $object2; } /* class MyCloneable { public function __invoke($object1,$object2) { $this->oject1=$object1; $this->oject2=$object2; } }*/ $obj = new MyCloneable(); $obj->object1 = new SubObject(); $obj->object2 = new SubObject(); $obj2=new $obj $obj2->object1 = new SubObject(); $obj2->object2 = new SubObject(); print("Oggetto originale:\n"); print_r($obj); print("Oggetto originale:\n"); print_r($obj2); ?>
Output for 5.4.0 - 5.4.19
Parse error: syntax error, unexpected '$obj2' (T_VARIABLE) in /in/E9kcJ on line 37
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE in /in/E9kcJ on line 37
Process exited with code 255.

preferences:
175.9 ms | 1395 KiB | 55 Q