3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { public $i = 0; function createANewBar() { ++$i; return null; } } class no_construct { } class a_construct { public function __construct() { } } $myFoo = new foo; echo $myFoo->i.PHP_EOL; $class = 'no_construct'; $object = new $class($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL; $object = new no_construct($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL; $class = 'a_construct'; $object = new $class($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL; $object = new a_construct($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL;
Output for hhvm-3.10.0 - 3.12.0, 7.1.0
0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0
Output for 5.0.4 - 5.6.28, 7.0.0 - 7.0.14
0 0 0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0
Output for 5.0.2 - 5.0.3
0 0 0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0 Notice: Undefined variable: i in /in/BFF9Y on line 3 0
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/BFF9Y on line 11 0PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/BFF9Y on line 17 0PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/BFF9Y on line 21 0PHP_EOL Notice: Undefined variable: i in /in/BFF9Y on line 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/BFF9Y on line 27 0PHP_EOL Notice: Undefined variable: i in /in/BFF9Y on line 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/BFF9Y on line 31 0PHP_EOL
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/BFF9Y 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/BFF9Y 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/BFF9Y on line 3
Process exited with code 255.