3v4l.org

run code in 300+ PHP versions simultaneously
<?php // mock $_GET['f'] = 'imagenes'; $_GET['folder'] = 'foods'; $_GET['type'] = 'salads'; $_GET['desc'] = 'green'; $_GET['dim'] = '50'; $_GET['id'] = '23'; // define expected $params = ['f', 'folder', 'type', 'desc', 'dim', 'id']; // loop over and output: /imagenes/foods/salads/green_50/23.png $path = null; foreach ($params as $key => $param) { if (isset($_GET[$param])) { $path .= ($param == 'dim' ? '_' : '/').basename($_GET[$param]); unset($params[$key]); } } $path .= '.png'; echo $path; __halt_compiler(); // check all params were passed if (!empty($params)) { die('Invalid request'); } // check file exists if (!file_exists($path)) { die('File does not exist'); } // check file is image if (!getimagesize($path)) { die('Invalid image'); } // all good serve file header("Content-Type: image/png"); header('Content-Length: '.filesize($path)); readfile($path);
Output for git.master, git.master_jit, rfc.property-hooks
/imagenes/foods/salads/green_50/23.png

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.33 ms | 401 KiB | 8 Q