3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Header { public function __construct() { $this->project = get_prior_object(); $this->modules = get_prior_object(1); } } class Modules { public function __construct() { $this->project = get_prior_object(); $this->header = new Header(); } } class Project { public $config = "config"; public function __construct() { $this->modules = new Modules(); } } $p = new Project(); var_dump($p->modules); function get_prior_object($skip = 0) { $bt = debug_backtrace(); foreach ($bt as $stack) { if (isset($stack['function']) && stack['function'] === "__construct" && $skip-- <= 0) { return $stack['object']; } } return null; }
Output for 5.6.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 Notice: Use of undefined constant stack - assumed 'stack' in /in/3eJGv on line 38 Warning: Illegal string offset 'function' in /in/3eJGv on line 38 object(Modules)#2 (2) { ["project"]=> NULL ["header"]=> object(Header)#3 (2) { ["project"]=> NULL ["modules"]=> NULL } }
Output for hhvm-3.10.0 - 3.12.0
Fatal error: syntax error, unexpected '[' in /in/3eJGv on line 38
Process exited with code 255.
Output for 5.1.0 - 5.5.35
Parse error: syntax error, unexpected '[' in /in/3eJGv on line 38
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/3eJGv on line 38
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/3eJGv on line 5
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/3eJGv 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/3eJGv on line 5
Process exited with code 255.