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 = array( 'a.jpg', 'b.GIF', 'C.png', 'd.JPEG', 'e.jpg', 'f.tiff', 'g.png', 'h.bmp', 'i.jpg', 'j.GIF', 'k.png', ); array_walk($images, function (&$v) use ($url) { $v = $url . $v; }); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>画像</title> </head> <body> <h1><?=$dir?>内の画像一覧</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 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>画像</title> </head> <body> <h1>C:\Program Files\Apache Group\Apache2\htdocs\img内の画像一覧</h1> <table> <tr> <td><img src="http://localhost/img/a.jpg"></td> <td><img src="http://localhost/img/b.GIF"></td> <td><img src="http://localhost/img/C.png"></td> <td><img src="http://localhost/img/d.JPEG"></td> <td><img src="http://localhost/img/e.jpg"></td> </tr> <tr> <td><img src="http://localhost/img/f.tiff"></td> <td><img src="http://localhost/img/g.png"></td> <td><img src="http://localhost/img/h.bmp"></td> <td><img src="http://localhost/img/i.jpg"></td> <td><img src="http://localhost/img/j.GIF"></td> </tr> <tr> <td><img src="http://localhost/img/k.png"></td> </tr> </table> </body> </html>
Output for 5.3.0 - 5.3.29
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>画像</title> </head> <body> <h1><?=$dir?>内の画像一覧</h1> <table> <tr> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> </tr> <tr> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> <td><img src="<?=$img?>"></td> </tr> <tr> <td><img src="<?=$img?>"></td> </tr> </table> </body> </html>
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/Mh8Lk on line 21
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
Parse error: parse error, unexpected T_FUNCTION in /in/Mh8Lk on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Mh8Lk on line 21
Process exited with code 255.

preferences:
208.78 ms | 401 KiB | 313 Q