3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $name; private $age; private $gender; public static $time; function __construct($name, $age, $gender, DateTime $time) { $this->name = $name; $this->age = $age; $this->gender = $gender; self::$time = $time->getTimestamp(); } } $foo = new Foo('hchen', 10, 'M', new DateTime('now')); $newFoo = Closure::bind( function() { return get_object_vars($this); }, $foo, 'Foo'); print_r(PHP_EOL.'<pre>========== START DEBUG: $newFoo =========='.PHP_EOL); print_r($newFoo()); print_r(PHP_EOL.'========== END OF $newFoo DEBUG ==========</pre>'.PHP_EOL); die(); ?>

preferences:
32.28 ms | 402 KiB | 5 Q