3v4l.org

run code in 300+ PHP versions simultaneously
<?php $path = '/home/example/public_html/temp/'; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { $path_parts = pathinfo($path . $file); $fileName = $path_parts['filename']; if((time() - strtotime($fileName)) > 24*30*3600) { unlink($path . $file); } } closedir($handle); } ?>
Output for 8.0.1 - 8.0.20, 8.1.0 - 8.1.7
Warning: opendir(): open_basedir restriction in effect. File(/home/example/public_html/temp/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/pKrnt on line 3 Warning: opendir(/home/example/public_html/temp/): Failed to open directory: Operation not permitted in /in/pKrnt on line 3
Output for 7.4.0 - 7.4.30
Warning: opendir(): open_basedir restriction in effect. File(/home/example/public_html/temp/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/pKrnt on line 3 Warning: opendir(/home/example/public_html/temp/): failed to open dir: Operation not permitted in /in/pKrnt on line 3

preferences:
63.15 ms | 407 KiB | 5 Q