3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Sample URLs. In practice there'd just be one which comes from $_SERVER['REQUEST_URI'] $urls = [ 'https://example.com', 'https://example.com/', 'https://example.com/en', 'https://example.com/en/', 'https://example.com/en/something', 'https://example.com/en/something/cheese', 'https://example.com/en/something/cheese/stuff', ]; foreach($urls as $url){ $urlParts = parse_url($url); $path = $urlParts['path'] ?? '/'; $pathParts = array_values(array_filter(explode('/', $path))); $lang = $menu = $page = $key = null; echo 'Url tested: ' . $url; echo PHP_EOL; if(!$pathParts){ echo 'Home'; }else{ // I would probably write this with a switch on the count(pathParts), or do some better // parsing here maybe, but this just shows what could happen @[0 => $lang, 1 => $menu, 2 => $page, 3 => $key] = $pathParts; echo sprintf('Lang=%1$s, Menu=%2$s, Page=%3$s, Key=%4$s', $lang, $menu, $page, $key); } echo PHP_EOL, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 56
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 56
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/mX5Pr
function name:  (null)
number of ops:  58
compiled vars:  !0 = $urls, !1 = $url, !2 = $urlParts, !3 = $path, !4 = $pathParts, !5 = $lang, !6 = $menu, !7 = $page, !8 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, <array>
   15     1      > FE_RESET_R                                           $10     !0, ->56
          2    > > FE_FETCH_R                                                   $10, !1, ->56
   16     3    >   INIT_FCALL                                                   'parse_url'
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $11     
          6        ASSIGN                                                       !2, $11
   17     7        FETCH_DIM_IS                                         ~13     !2, 'path'
          8        COALESCE                                             ~14     ~13
          9        QM_ASSIGN                                            ~14     '%2F'
         10        ASSIGN                                                       !3, ~14
   19    11        INIT_FCALL                                                   'array_values'
         12        INIT_FCALL                                                   'array_filter'
         13        INIT_FCALL                                                   'explode'
         14        SEND_VAL                                                     '%2F'
         15        SEND_VAR                                                     !3
         16        DO_ICALL                                             $16     
         17        SEND_VAR                                                     $16
         18        DO_ICALL                                             $17     
         19        SEND_VAR                                                     $17
         20        DO_ICALL                                             $18     
         21        ASSIGN                                                       !4, $18
   21    22        ASSIGN                                               ~20     !8, null
         23        ASSIGN                                               ~21     !7, ~20
         24        ASSIGN                                               ~22     !6, ~21
         25        ASSIGN                                                       !5, ~22
   23    26        CONCAT                                               ~24     'Url+tested%3A+', !1
         27        ECHO                                                         ~24
   24    28        ECHO                                                         '%0A'
   26    29        BOOL_NOT                                             ~25     !4
         30      > JMPZ                                                         ~25, ->33
   27    31    >   ECHO                                                         'Home'
   26    32      > JMP                                                          ->53
   31    33    >   BEGIN_SILENCE                                        ~26     
         34        QM_ASSIGN                                            ~27     !4
         35        FETCH_LIST_R                                         $28     ~27, 0
         36        ASSIGN                                                       !5, $28
         37        FETCH_LIST_R                                         $30     ~27, 1
         38        ASSIGN                                                       !6, $30
         39        FETCH_LIST_R                                         $32     ~27, 2
         40        ASSIGN                                                       !7, $32
         41        FETCH_LIST_R                                         $34     ~27, 3
         42        ASSIGN                                                       !8, $34
         43        END_SILENCE                                                  ~26
         44        FREE                                                         ~27
   32    45        INIT_FCALL                                                   'sprintf'
         46        SEND_VAL                                                     'Lang%3D%251%24s%2C+Menu%3D%252%24s%2C+Page%3D%253%24s%2C+Key%3D%254%24s'
         47        SEND_VAR                                                     !5
         48        SEND_VAR                                                     !6
         49        SEND_VAR                                                     !7
         50        SEND_VAR                                                     !8
         51        DO_ICALL                                             $36     
         52        ECHO                                                         $36
   35    53    >   ECHO                                                         '%0A'
         54        ECHO                                                         '%0A'
   15    55      > JMP                                                          ->2
         56    >   FE_FREE                                                      $10
   36    57      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.6 ms | 1665 KiB | 18 Q