3v4l.org

run code in 300+ PHP versions simultaneously
<?php $var = new class { public $data; public function __construct($data) { $this->data = $data; } } ("Hello World"); var_dump($var); interface IObject { public function iMethod(); } function my_function(IObject $object) { return $object->iMethod(); } var_dump(my_function(new class implements IObject { public function iMethod() { return __METHOD__; } }));
Output for 5.4.0 - 5.4.20, 5.5.0 - 5.5.4
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/H7Hip on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_CLASS in /in/H7Hip on line 3
Process exited with code 255.

preferences:
178.88 ms | 1395 KiB | 61 Q