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 { const QUERY_NAMESPACE = SelectUserById::class; } $instance = (new SelectUserByIdFactory)('container here'); $instance->vai();
Output for 7.0.0 - 7.2.1
Fatal error: Uncaught Error: Class 'QUERY_NAMESPACE' not found in /in/AFRQv:22 Stack trace: #0 /in/AFRQv(31): QueryFactory->__invoke('container here') #1 {main} thrown in /in/AFRQv on line 22
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected '(' in /in/AFRQv:-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 '(' in /in/AFRQv:31 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '(' in /in/AFRQv on line 31
Process exited with code 255.