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);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 40
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 40
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 39
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 39
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/tTALQ
function name:  (null)
number of ops:  44
compiled vars:  !0 = $params, !1 = $path, !2 = $param, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   FETCH_W                      global              $4      '_GET'
          1        ASSIGN_DIM                                               $4, 'f'
          2        OP_DATA                                                  'imagenes'
    5     3        FETCH_W                      global              $6      '_GET'
          4        ASSIGN_DIM                                               $6, 'folder'
          5        OP_DATA                                                  'foods'
    6     6        FETCH_W                      global              $8      '_GET'
          7        ASSIGN_DIM                                               $8, 'type'
          8        OP_DATA                                                  'salads'
    7     9        FETCH_W                      global              $10     '_GET'
         10        ASSIGN_DIM                                               $10, 'desc'
         11        OP_DATA                                                  'green'
    8    12        FETCH_W                      global              $12     '_GET'
         13        ASSIGN_DIM                                               $12, 'dim'
         14        OP_DATA                                                  '50'
    9    15        FETCH_W                      global              $14     '_GET'
         16        ASSIGN_DIM                                               $14, 'id'
         17        OP_DATA                                                  '23'
   12    18        ASSIGN                                                   !0, <array>
   15    19        ASSIGN                                                   !1, null
   16    20      > FE_RESET_R                                       $18     !0, ->40
         21    > > FE_FETCH_R                                       ~19     $18, !2, ->40
         22    >   ASSIGN                                                   !3, ~19
   17    23        FETCH_IS                                         ~21     '_GET'
         24        ISSET_ISEMPTY_DIM_OBJ                         0          ~21, !2
         25      > JMPZ                                                     ~22, ->39
   18    26    >   IS_EQUAL                                                 !2, 'dim'
         27      > JMPZ                                                     ~23, ->30
         28    >   QM_ASSIGN                                        ~24     '_'
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~24     '%2F'
         31    >   INIT_FCALL                                               'basename'
         32        FETCH_R                      global              ~25     '_GET'
         33        FETCH_DIM_R                                      ~26     ~25, !2
         34        SEND_VAL                                                 ~26
         35        DO_ICALL                                         $27     
         36        CONCAT                                           ~28     ~24, $27
         37        ASSIGN_OP                                     8          !1, ~28
   19    38        UNSET_DIM                                                !0, !3
   16    39    > > JMP                                                      ->21
         40    >   FE_FREE                                                  $18
   22    41        ASSIGN_OP                                     8          !1, '.png'
   24    42        ECHO                                                     !1
   26    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.47 ms | 1405 KiB | 15 Q