3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait ClosureInATrait { public static function getClosureInTrait() { return function () { return __CLASS__; } } } class ClassConstantTest { use ClosureInATrait; public static function getClosureInClass() { return function () { return __CLASS__; } } } $closureInClass = ClassConstantTest::getClosureInClass(); $closureInTrait = ClassConstantTest::getClosureInTrait(); var_dump($closureInClass(), $closureInTrait()); $closureInClass = Closure::bind($closureInClass, new stdClass()); $closureInTrait = Closure::bind($closureInTrait, new stdClass()); var_dump($closureInClass(), $closureInTrait());
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected '}' in /in/nY4Oo on line 10
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING in /in/nY4Oo on line 3
Process exited with code 255.

preferences:
183.52 ms | 1399 KiB | 67 Q