3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //include('/etc/profile'); $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); echo $_SERVER["DOCUMENT_ROOT"]; $dir = '/usr/local/'; $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: scandir(): open_basedir restriction in effect. File(/usr/local/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/nfuTm on line 13 Warning: scandir(/usr/local/): failed to open dir: Operation not permitted in /in/nfuTm on line 13 Warning: scandir(): (errno 1): Operation not permitted in /in/nfuTm on line 13 Warning: scandir(): open_basedir restriction in effect. File(/usr/local/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/nfuTm on line 14 Warning: scandir(/usr/local/): failed to open dir: Operation not permitted in /in/nfuTm on line 14 Warning: scandir(): (errno 1): Operation not permitted in /in/nfuTm on line 14
Output for hhvm-3.15.4 - 3.22.0
Array ( [0] => . [1] => .. [2] => bin [3] => etc [4] => games [5] => include [6] => lib [7] => man [8] => sbin [9] => share [10] => src ) Array ( [0] => src [1] => share [2] => sbin [3] => man [4] => lib [5] => include [6] => games [7] => etc [8] => bin [9] => .. [10] => . )