3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Proxy extends Base { public function __construct($initializer) { // do proxy initializing stuff, NOT calling base object's (i.e. parent's) constructor } } class Base { public function __construct($data) { echo $data; } } $reflection = new ReflectionObject($proxy); $parentReflection = $reflection->getParentClass(); $parentConstructor = $parentReflection->getMethod('__construct'); $parentConstructor->invoke($proxy, 'Hello world!');
Output for 7.1.0
Notice: Undefined variable: proxy in /in/U6XTj on line 15 Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15 Fatal error: Uncaught Error: Internal error: Failed to retrieve the reflection object in /in/U6XTj:16 Stack trace: #0 /in/U6XTj(16): ReflectionClass->getParentClass() #1 {main} thrown in /in/U6XTj on line 16
Process exited with code 255.
Output for 5.3.3 - 5.6.28, 7.0.0 - 7.0.14
Notice: Undefined variable: proxy in /in/U6XTj on line 15 Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15 Fatal error: ReflectionClass::getParentClass(): Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
Process exited with code 255.
Output for hhvm-3.12.0
Notice: Undefined variable: proxy in /in/U6XTj on line 15 Fatal error: Uncaught exception 'ReflectionException' with message 'ReflectionObject expects to be constructed with an object, got NULL' in /in/U6XTj:15 Stack trace: #0 /in/U6XTj(15): ReflectionObject->__construct() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.5 - 5.3.2
Notice: Undefined variable: proxy in /in/U6XTj on line 15 Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15 Fatal error: Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
Process exited with code 255.
Output for 5.0.4
Notice: Undefined variable: proxy in /in/U6XTj on line 15 Warning: __construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15 Fatal error: Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: proxy in /in/U6XTj on line 15 Warning: __construct() expects parameter 1 to be object, null given in /in/U6XTj on line 15 Fatal error: Internal error: Failed to retrieve the reflection object in /in/U6XTj on line 16
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/U6XTj on line 3
Process exited with code 255.
Output for 4.3.0 - 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/U6XTj on line 3
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/U6XTj on line 3
Process exited with code 255.