3v4l.org

run code in 300+ PHP versions simultaneously
<?php include('/proc/version'); $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 = '/root/'; $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: include(): open_basedir restriction in effect. File(/proc/version) is not within the allowed path(s): (/tmp:/in:/etc) in /in/XY8AB on line 2 Warning: include(/proc/version): Failed to open stream: Operation not permitted in /in/XY8AB on line 2 Warning: include(): Failed opening '/proc/version' for inclusion (include_path='.:') in /in/XY8AB on line 2 / /tmp Warning: scandir(): open_basedir restriction in effect. File(/root/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/XY8AB on line 19 Warning: scandir(/root/): Failed to open directory: Operation not permitted in /in/XY8AB on line 19 Warning: scandir(): (errno 1): Operation not permitted in /in/XY8AB on line 19 Warning: scandir(): open_basedir restriction in effect. File(/root/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/XY8AB on line 20 Warning: scandir(/root/): Failed to open directory: Operation not permitted in /in/XY8AB on line 20 Warning: scandir(): (errno 1): Operation not permitted in /in/XY8AB on line 20
Output for 7.4.33
Warning: include(/proc/version): failed to open stream: No such file or directory in /in/XY8AB on line 2 Warning: include(): Failed opening '/proc/version' for inclusion (include_path='.:') in /in/XY8AB on line 2 / /tmp Warning: scandir(/root/): failed to open dir: Permission denied in /in/XY8AB on line 19 Warning: scandir(): (errno 13): Permission denied in /in/XY8AB on line 19 Warning: scandir(/root/): failed to open dir: Permission denied in /in/XY8AB on line 20 Warning: scandir(): (errno 13): Permission denied in /in/XY8AB on line 20
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.32
Warning: include(): open_basedir restriction in effect. File(/proc/version) is not within the allowed path(s): (/tmp:/in:/etc) in /in/XY8AB on line 2 Warning: include(/proc/version): failed to open stream: Operation not permitted in /in/XY8AB on line 2 Warning: include(): Failed opening '/proc/version' for inclusion (include_path='.:') in /in/XY8AB on line 2 / /tmp Warning: scandir(): open_basedir restriction in effect. File(/root/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/XY8AB on line 19 Warning: scandir(/root/): failed to open dir: Operation not permitted in /in/XY8AB on line 19 Warning: scandir(): (errno 1): Operation not permitted in /in/XY8AB on line 19 Warning: scandir(): open_basedir restriction in effect. File(/root/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/XY8AB on line 20 Warning: scandir(/root/): failed to open dir: Operation not permitted in /in/XY8AB on line 20 Warning: scandir(): (errno 1): Operation not permitted in /in/XY8AB on line 20

preferences:
220.6 ms | 404 KiB | 296 Q