3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // ClassA.php class A { public function __construct(){print "Init";} public function bye(){print "Hey :)";} } //ScriptAClassAction.php require 'ClassA.php'; $class = new A(); $reflection = new ReflectionClass($class); if (!empty($reflection) && $reflection->hasMethod('hello')){ if($reflection->hasMethod('init')) $class->init($request, $response); //Prints 'Init called' if($reflection->hasMethod('preDispatch')) $class->preDispatch(); // 'Predispatch called' $class->hello(); if($reflection->hasMethod('postDispatch')) $class->postDispatch(); // 'post dispatch called'.. } else { if (!$reflection) // I know this might not be the best check but.. print "Not a valid class supplied"; if (false == $reflection->hasMethod('hello')) // True trigger print "Supplied class does not have any manners and does not greet you :D"; // This is the expected output and it should be the only output }
Output for 5.3.28 - 5.3.29, 5.4.18 - 5.6.28, 7.0.0 - 7.1.0
Warning: require(ClassA.php): failed to open stream: No such file or directory in /in/Dgga5 on line 11 Fatal error: require(): Failed opening required 'ClassA.php' (include_path='.:') in /in/Dgga5 on line 11
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: File not found: ClassA.php in /in/Dgga5 on line 11
Process exited with code 255.
Output for 5.1.0 - 5.3.27, 5.4.0 - 5.4.17
Warning: require(ClassA.php): failed to open stream: No such file or directory in /in/EmSNu on line 11 Fatal error: require(): Failed opening required 'ClassA.php' (include_path='.:') in /in/EmSNu on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: main(ClassA.php): failed to open stream: No such file or directory in /in/EmSNu on line 11 Fatal error: main(): Failed opening required 'ClassA.php' (include_path='.:') in /in/EmSNu on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/EmSNu on line 5
Process exited with code 255.
Output for 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/EmSNu on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/EmSNu on line 5
Process exited with code 255.
Output for 4.3.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Dgga5 on line 5
Process exited with code 255.