3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'http://localhost/img'; $dir = 'C:\Program Files\Apache Group\Apache2\htdocs\img'; $max = 5; $images = preg_grep('/\.(?:jpe?g|gif|png)\z/i', scandir($dir)); array_walk($images, function (&$v) { $v = $url . $v; }); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1><?=$path?>内の画像一覧</h1> <?php if (!$images): ?> <p>表示する画像はありません</p> <?php else: ?> <table> <tr> <?php foreach ($images as $i => $img): ?> <?php if ($i !== 0 && $i % $max === 0): ?> </tr> <tr> <?php endif; ?> <td><img src="<?=$img?>"></td> <?php endforeach; ?> </tr> </table> <?php endif; ?> </body> </html>
Output for 8.3.0 - 8.3.6
Warning: scandir(): open_basedir restriction in effect. File(C:\Program Files\Apache Group\Apache2\htdocs\img) is not within the allowed path(s): (/tmp:/in:/etc) in /in/uI4VA on line 7 Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): Failed to open directory: Operation not permitted in /in/uI4VA on line 7 Warning: scandir(): (errno 1): Operation not permitted in /in/uI4VA on line 7 Fatal error: Uncaught TypeError: preg_grep(): Argument #2 ($array) must be of type array, false given in /in/uI4VA:7 Stack trace: #0 /in/uI4VA(7): preg_grep('/\\.(?:jpe?g|gif...', false) #1 {main} thrown in /in/uI4VA on line 7
Process exited with code 255.
Output for 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: scandir(): open_basedir restriction in effect. File(C:\Program Files\Apache Group\Apache2\htdocs\img) is not within the allowed path(s): (/tmp:/in:/etc) in /in/uI4VA on line 7 Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): Failed to open directory: Operation not permitted in /in/uI4VA on line 7 Warning: scandir(): (errno 1): Operation not permitted in /in/uI4VA on line 7 Fatal error: Uncaught TypeError: preg_grep(): Argument #2 ($array) must be of type array, bool given in /in/uI4VA:7 Stack trace: #0 /in/uI4VA(7): preg_grep('/\\.(?:jpe?g|gif...', false) #1 {main} thrown in /in/uI4VA on line 7
Process exited with code 255.
Output for 8.0.0 - 8.0.13
Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): Failed to open directory: No such file or directory in /in/uI4VA on line 7 Warning: scandir(): (errno 2): No such file or directory in /in/uI4VA on line 7 Fatal error: Uncaught TypeError: preg_grep(): Argument #2 ($array) must be of type array, bool given in /in/uI4VA:7 Stack trace: #0 /in/uI4VA(7): preg_grep('/\\.(?:jpe?g|gif...', false) #1 {main} thrown in /in/uI4VA on line 7
Process exited with code 255.
Output for 7.4.33
Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): failed to open dir: No such file or directory in /in/uI4VA on line 7 Warning: scandir(): (errno 2): No such file or directory in /in/uI4VA on line 7 Warning: preg_grep() expects parameter 2 to be array, bool given in /in/uI4VA on line 7 Warning: array_walk() expects parameter 1 to be array, null given in /in/uI4VA on line 10 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1> Notice: Undefined variable: path in /in/uI4VA on line 19 内の画像一覧</h1> <p>表示する画像はありません</p> </body> </html>
Output for 7.4.27 - 7.4.32
Warning: scandir(): open_basedir restriction in effect. File(C:\Program Files\Apache Group\Apache2\htdocs\img) is not within the allowed path(s): (/tmp:/in:/etc) in /in/uI4VA on line 7 Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): failed to open dir: Operation not permitted in /in/uI4VA on line 7 Warning: scandir(): (errno 1): Operation not permitted in /in/uI4VA on line 7 Warning: preg_grep() expects parameter 2 to be array, bool given in /in/uI4VA on line 7 Warning: array_walk() expects parameter 1 to be array, null given in /in/uI4VA on line 10 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1> Notice: Undefined variable: path in /in/uI4VA on line 19 内の画像一覧</h1> <p>表示する画像はありません</p> </body> </html>
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.26
Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): failed to open dir: No such file or directory in /in/uI4VA on line 7 Warning: scandir(): (errno 2): No such file or directory in /in/uI4VA on line 7 Warning: preg_grep() expects parameter 2 to be array, bool given in /in/uI4VA on line 7 Warning: array_walk() expects parameter 1 to be array, null given in /in/uI4VA on line 10 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1>内の画像一覧</h1> <p>表示する画像はありません</p> </body> </html>
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34
Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): failed to open dir: No such file or directory in /in/uI4VA on line 7 Warning: scandir(): (errno 2): No such file or directory in /in/uI4VA on line 7 Warning: preg_grep() expects parameter 2 to be array, boolean given in /in/uI4VA on line 7 Warning: array_walk() expects parameter 1 to be array, null given in /in/uI4VA on line 10 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1>内の画像一覧</h1> <p>表示する画像はありません</p> </body> </html>
Output for 5.3.0 - 5.3.29
Warning: scandir(C:\Program Files\Apache Group\Apache2\htdocs\img): failed to open dir: No such file or directory in /in/uI4VA on line 7 Warning: scandir(): (errno 2): No such file or directory in /in/uI4VA on line 7 Warning: preg_grep() expects parameter 2 to be array, boolean given in /in/uI4VA on line 7 Warning: array_walk() expects parameter 1 to be array, null given in /in/uI4VA on line 10 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1><?=$path?>内の画像一覧</h1> <p>表示する画像はありません</p> </body> </html>
Output for 5.2.3 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/uI4VA on line 8
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected T_FUNCTION in <b>/in/uI4VA</b> on line <b>8</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected T_FUNCTION in <b>/in/uI4VA</b> on line <b>8</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/uI4VA</b> on line <b>8</b><br />
Process exited with code 255.

preferences:
249.87 ms | 401 KiB | 468 Q