3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php include('/tmp/test.txt'); $myfile = fopen("/tmp/test.txt", "w") or die("Unable to open file!"); $txt = "John Doe\n"; fwrite($myfile, $txt); $txt = "Jane Doe\n"; fwrite($myfile, $txt); fclose($myfile); // current directory echo getcwd() . "\n"; chdir('/tmp'); // current directory echo getcwd() . "\n"; $dir = '/tmp'; $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2);
Output for 5.6.30, 7.0.0 - 7.1.12, 7.1.14 - 7.2.4, 7.2.6 - 7.2.9
Warning: include(/tmp/test.txt): failed to open stream: No such file or directory in /in/of6pl on line 2 Warning: include(): Failed opening '/tmp/test.txt' for inclusion (include_path='.:') in /in/of6pl on line 2 / /tmp Array ( [0] => . [1] => .. [2] => test.txt ) Array ( [0] => test.txt [1] => .. [2] => . )
Output for 7.2.5
Warning: include(/tmp/test.txt): failed to open stream: No such file or directory in /in/of6pl on line 2 Warning: include(): Failed opening '/tmp/test.txt' for inclusion (include_path='.:') in /in/of6pl on line 2 / /tmp Array ( [0] => . [1] => .. [2] => perf-10033.map [3] => test.txt ) Array ( [0] => test.txt [1] => perf-10033.map [2] => .. [3] => . )
Output for 7.1.13
Warning: include(/tmp/test.txt): failed to open stream: No such file or directory in /in/of6pl on line 2 Warning: include(): Failed opening '/tmp/test.txt' for inclusion (include_path='.:') in /in/of6pl on line 2 / /tmp Array ( [0] => . [1] => .. [2] => perf-10056.map [3] => test.txt ) Array ( [0] => test.txt [1] => perf-10056.map [2] => .. [3] => . )
Output for hhvm-3.22.0
Warning: include(/tmp/test.txt): File not found in /in/of6pl on line -1 / /tmp Array ( [0] => . [1] => .. [2] => test.txt ) Array ( [0] => test.txt [1] => .. [2] => . )
Output for hhvm-3.15.4 - 3.18.4, hhvm-3.19.2 - 3.21.3
Warning: include(/tmp/test.txt): File not found in /in/of6pl on line 2 / /tmp Array ( [0] => . [1] => .. [2] => test.txt ) Array ( [0] => test.txt [1] => .. [2] => . )
Output for hhvm-3.18.5
Warning: include(/tmp/test.txt): File not found in /in/of6pl on line 2 / /tmp Array ( [0] => . [1] => .. [2] => perf-10084.map [3] => test.txt ) Array ( [0] => test.txt [1] => perf-10084.map [2] => .. [3] => . )