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) { $class = self::QUERY_NAMESPACE; return new $class($container); } } final class SelectUserByIdFactory extends QueryFactory { const QUERY_NAMESPACE = SelectUserById::class; } $instance = (new SelectUserByIdFactory)('container here'); $instance->vai();
based on hF2Vm
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught Error: Undefined class constant 'QUERY_NAMESPACE' in /in/oYm2W:22 Stack trace: #0 /in/oYm2W(32): QueryFactory->__invoke('container here') #1 {main} thrown in /in/oYm2W on line 22
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected '(' in /in/oYm2W:-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/oYm2W:32 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '(' in /in/oYm2W on line 32
Process exited with code 255.