3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class SelectUserById { private $container; public function __construct($container) { $this->container = $container; } public function vai() { echo $this->container; } } abstract class QueryFactory { public function __invoke($container) { return new QUERY_NAMESPACE($container); } } final class SelectUserByIdFactory extends QueryFactory { public const QUERY_NAMESPACE = SelectUserById::class; } $instance = (new SelectUserByIdFactory)('container here'); $instance->vai();
based on nuUKv
Output for 7.1.0 - 7.2.1
Fatal error: Uncaught Error: Class 'QUERY_NAMESPACE' not found in /in/FG8Mb:22 Stack trace: #0 /in/FG8Mb(31): QueryFactory->__invoke('container here') #1 {main} thrown in /in/FG8Mb on line 22
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.27
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /in/FG8Mb on line 28
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected T_CONST, expecting T_VARIABLE in /in/FG8Mb:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: syntax error, unexpected T_CONST, expecting T_VARIABLE in /in/FG8Mb:28 Stack trace: #0 {main}
Process exited with code 255.