3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // overly simplified example function test1() { $a = 3; test2(); } function test2() { echo $a; } // the actual idea is to do something like this // main.php $vars = []; function load_file($path) { if(is_file($path)) { $GLOBALS['path'] = $path; load_isolated(); } } function load_isolated() { extract($GLOBALS['vars']); require($GLOBALS['path']); $GLOBALS['vars'] = get_defined_vars(); } load_file('a.php'); // a.php $a = 3; load_file('b.php'); //b.php echo $a; // warning or error that var $a doesn't exist because get_defined_vars() was never called yata yata
Output for 5.6.0 - 5.6.30, hhvm-3.18.4 - 3.21.0, 7.0.0 - 7.1.8
3