3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function foo() { global $color; include 'vars.php'; echo "A $color $fruit"; } /* vars.php is in the scope of foo() so * * $fruit is NOT available outside of this * * scope. $color is because we declared it * * as global. */ foo(); // A green apple echo "A $color $fruit"; // A green ?>
Output for 5.3.7 - 5.6.28, 7.0.0 - 7.1.0
Warning: include(vars.php): failed to open stream: No such file or directory in /in/4KvaP on line 7 Warning: include(): Failed opening 'vars.php' for inclusion (include_path='.:') in /in/4KvaP on line 7 Notice: Undefined variable: fruit in /in/4KvaP on line 9 A Notice: Undefined variable: fruit in /in/4KvaP on line 18 A
Output for hhvm-3.10.0 - 3.12.0
Warning: File not found: vars.php in /in/4KvaP on line 7 Notice: Undefined variable: fruit in /in/4KvaP on line 9 A Notice: Undefined variable: fruit in /in/4KvaP on line 18 A