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 = '/var/www/'; $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2);
Output for 5.6.30, 7.0.0 - 7.2.9
Warning: include(/tmp/test.txt): failed to open stream: No such file or directory in /in/ZiAeY on line 2 Warning: include(): Failed opening '/tmp/test.txt' for inclusion (include_path='.:') in /in/ZiAeY on line 2 / /tmp Warning: scandir(): open_basedir restriction in effect. File(/var/www/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ZiAeY on line 19 Warning: scandir(/var/www/): failed to open dir: Operation not permitted in /in/ZiAeY on line 19 Warning: scandir(): (errno 1): Operation not permitted in /in/ZiAeY on line 19 Warning: scandir(): open_basedir restriction in effect. File(/var/www/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ZiAeY on line 20 Warning: scandir(/var/www/): failed to open dir: Operation not permitted in /in/ZiAeY on line 20 Warning: scandir(): (errno 1): Operation not permitted in /in/ZiAeY on line 20
Output for hhvm-3.22.0
Warning: include(/tmp/test.txt): File not found in /in/ZiAeY on line -1 / /tmp Warning: No such file or directory in /in/ZiAeY on line -1 Warning: No such file or directory in /in/ZiAeY on line -1
Output for hhvm-3.15.4 - 3.21.3
Warning: include(/tmp/test.txt): File not found in /in/ZiAeY on line 2 / /tmp Warning: No such file or directory in /in/ZiAeY on line 19 Warning: No such file or directory in /in/ZiAeY on line 20