3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function get_files($path){ $folder = opendir($path); while ($dat = readdir($folder)){ if ($dat != "." && $dat != ".." && (is_dir($path."/".$dat) || substr($dat,-3) == "jpg" || substr($dat,-3) == "gif" || substr($dat,-3) == "bmp" || substr($dat,-3) == "png")){ if (is_dir($path."/".$dat)){ $dirs[] = get_files($path."/".$dat); } else{ $files[] = $path."/".$dat; } } } for ($i=0; $i<sizeof($dirs); $i++){ $files2 = array_merge($files2,$dirs[$i]); } $array = array_merge($files,$files2); return $array; } $path = "../test"; // Pfad zum Startverzeichnis $amount = sizeof(get_files($path)); for ($i=0; $i < $amount; $i++){ $files = get_files($path); $size += filesize($files[$i]); }
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: opendir(../test): failed to open dir: No such file or directory in /in/6I3u5 on line 3 Warning: readdir() expects parameter 1 to be resource, boolean given in /in/6I3u5 on line 4 Notice: Undefined variable: dirs in /in/6I3u5 on line 16 Notice: Undefined variable: files in /in/6I3u5 on line 20 Notice: Undefined variable: files2 in /in/6I3u5 on line 20 Warning: array_merge(): Argument #1 is not an array in /in/6I3u5 on line 20
Output for hhvm-3.10.0 - 3.12.0
Warning: No such file or directory in /in/6I3u5 on line 3 Warning: readdir() expects parameter 1 to be resource, boolean given in /in/6I3u5 on line 4 Notice: Undefined variable: dirs in /in/6I3u5 on line 16 Notice: Undefined variable: files in /in/6I3u5 on line 20 Notice: Undefined variable: files2 in /in/6I3u5 on line 20 Warning: array_merge() expects parameter 1 to be array, null given in /in/6I3u5 on line 20
Output for 5.0.4 - 5.2.17
Warning: opendir(../test): failed to open dir: No such file or directory in /in/6I3u5 on line 3 Warning: readdir(): supplied argument is not a valid Directory resource in /in/6I3u5 on line 4 Notice: Undefined variable: dirs in /in/6I3u5 on line 16 Notice: Undefined variable: files in /in/6I3u5 on line 20 Notice: Undefined variable: files2 in /in/6I3u5 on line 20 Warning: array_merge(): Argument #1 is not an array in /in/6I3u5 on line 20 Warning: array_merge(): Argument #2 is not an array in /in/6I3u5 on line 20
Output for 5.0.0 - 5.0.3
Warning: opendir(../test): failed to open dir: No such file or directory in /in/6I3u5 on line 3 Warning: readdir(): supplied argument is not a valid Directory resource in /in/6I3u5 on line 4 Notice: Undefined variable: dirs in /in/6I3u5 on line 16 Notice: Undefined variable: files in /in/6I3u5 on line 20 Notice: Undefined variable: files2 in /in/6I3u5 on line 20 Warning: array_merge(): Argument #1 is not an array in /in/6I3u5 on line 20 Warning: array_merge(): Argument #2 is not an array in /in/6I3u5 on line 20
Output for 4.3.2 - 4.4.9
Warning: opendir(../test): failed to open dir: No such file or directory in /in/6I3u5 on line 3 Warning: readdir(): supplied argument is not a valid Directory resource in /in/6I3u5 on line 4 Notice: Undefined variable: dirs in /in/6I3u5 on line 16 Notice: Undefined variable: files in /in/6I3u5 on line 20 Notice: Undefined variable: files2 in /in/6I3u5 on line 20
Output for 4.3.0 - 4.3.1
Warning: opendir(../test) [http://www.php.net/function.opendir]: failed to open dir: No such file or directory in /in/6I3u5 on line 3 Warning: readdir(): supplied argument is not a valid Directory resource in /in/6I3u5 on line 4 Notice: Undefined variable: dirs in /in/6I3u5 on line 16 Notice: Undefined variable: files in /in/6I3u5 on line 20 Notice: Undefined variable: files2 in /in/6I3u5 on line 20