3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Duplicates an array, even if the array contains * references. * * @param $arr array The array to duplicate. * @return array The duplicate of the array. */ function array_dup($arr) { $ret = []; foreach ($arr as $key => $value) $ret[$key] = $value; return $ret; } /** * Create an array of references to the elements of an array. * * @param $arr array The array to create references to. * @return array */ function refArray(&$arr) { $refs = []; foreach ($arr as $key => $value) $refs[$key] = &$arr[$key]; return $refs; } /** * Invokes a callback while capturing the output buffer * changes produced by it, and returns those changes as * a string. * * @param $callback callback The function to call. * @return string */ function captureOutputBuffer($callback) { ob_start(); $callback(); $dat = ob_get_contents(); if ($dat === false || ob_end_clean() !== true) throw new LogicException('ERROR: Something is wrong! Failed to retrieve the buffer\'s body!'); return $dat; } /** * Clean a partial page path of all invalid characters, * and ready it for lookup in the database. * * @param $path string The path to clean. * @return string A clean version of the path. */ function cleanPagePath($path) { $path = strtolower(rtrim($path, '/')); $tmp = ''; $pathLength = strlen($path); for ($i = 0; $i < $pathLength; $i++) { switch ($path[$i]) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '_': case '-': case '/': $tmp .= $path[$i]; continue; // Backslashes are looked up as forward slashes. case '\\': $tmp .= '/'; continue; // Spaces are replaced with underscores. case ' ': $tmp .= '_'; continue; default: continue; } } return $tmp; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LT8lL
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  124     0  E > > RETURN                                                   1

Function array_dup:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/LT8lL
function name:  array_dup
number of ops:  11
compiled vars:  !0 = $arr, !1 = $ret, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        ASSIGN                                                   !1, <array>
   13     2      > FE_RESET_R                                       $5      !0, ->8
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->8
          4    >   ASSIGN                                                   !3, ~6
   14     5        ASSIGN_DIM                                               !1, !3
          6        OP_DATA                                                  !2
   13     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $5
   15     9      > RETURN                                                   !1
   16    10*     > RETURN                                                   null

End of function array_dup

Function refarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/LT8lL
function name:  refArray
number of ops:  13
compiled vars:  !0 = $arr, !1 = $refs, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        ASSIGN                                                   !1, <array>
   27     2      > FE_RESET_R                                       $5      !0, ->10
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->10
          4    >   ASSIGN                                                   !3, ~6
   28     5        FETCH_DIM_W                                      $9      !0, !3
          6        MAKE_REF                                         $10     $9
          7        FETCH_DIM_W                                      $8      !1, !3
          8        ASSIGN_REF                                               $8, $10
   27     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $5
   29    11      > RETURN                                                   !1
   30    12*     > RETURN                                                   null

End of function refarray

Function captureoutputbuffer:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/LT8lL
function name:  captureOutputBuffer
number of ops:  21
compiled vars:  !0 = $callback, !1 = $dat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   42     1        INIT_FCALL                                               'ob_start'
          2        DO_ICALL                                                 
   43     3        INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0          
   44     5        INIT_FCALL                                               'ob_get_contents'
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !1, $4
   45     8        TYPE_CHECK                                    4  ~6      !1
          9      > JMPNZ_EX                                         ~6      ~6, ->14
         10    >   INIT_FCALL                                               'ob_end_clean'
         11        DO_ICALL                                         $7      
         12        TYPE_CHECK                                  1014  ~8      $7
         13        BOOL                                             ~6      ~8
         14    > > JMPZ                                                     ~6, ->19
   46    15    >   NEW                                              $9      'LogicException'
         16        SEND_VAL_EX                                              'ERROR%3A+Something+is+wrong%21+Failed+to+retrieve+the+buffer%27s+body%21'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $9
   47    19    > > RETURN                                                   !1
   48    20*     > RETURN                                                   null

End of function captureoutputbuffer

Function cleanpagepath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
2 jumps found. (Code = 44) Position 1 = 110, Position 2 = 14
Branch analysis from position: 110
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 98
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 98
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 98
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 98
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 98
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 98
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 98
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 98
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 98
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 98
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 98
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 98
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 98
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 98
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 98
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 98
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 98
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 98
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 98
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 98
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 98
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 98
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 98
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 98
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 65, Position 2 = 98
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 98
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 69, Position 2 = 98
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 98
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 98
Branch analysis from position: 73
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 98
Branch analysis from position: 75
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 98
Branch analysis from position: 77
2 jumps found. (Code = 44) Position 1 = 79, Position 2 = 98
Branch analysis from position: 79
2 jumps found. (Code = 44) Position 1 = 81, Position 2 = 98
Branch analysis from position: 81
2 jumps found. (Code = 44) Position 1 = 83, Position 2 = 98
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 85, Position 2 = 98
Branch analysis from position: 85
2 jumps found. (Code = 44) Position 1 = 87, Position 2 = 98
Branch analysis from position: 87
2 jumps found. (Code = 44) Position 1 = 89, Position 2 = 98
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 98
Branch analysis from position: 91
2 jumps found. (Code = 44) Position 1 = 93, Position 2 = 98
Branch analysis from position: 93
2 jumps found. (Code = 44) Position 1 = 95, Position 2 = 101
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 103
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 105
Branch analysis from position: 105
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
2 jumps found. (Code = 44) Position 1 = 110, Position 2 = 14
Branch analysis from position: 110
Branch analysis from position: 14
Branch analysis from position: 103
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 98
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
Branch analysis from position: 98
filename:       /in/LT8lL
function name:  cleanPagePath
number of ops:  112
compiled vars:  !0 = $path, !1 = $tmp, !2 = $pathLength, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
   59     1        INIT_FCALL                                               'strtolower'
          2        INIT_FCALL                                               'rtrim'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%2F'
          5        DO_ICALL                                         $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !0, $5
   60     9        ASSIGN                                                   !1, ''
   61    10        STRLEN                                           ~8      !0
         11        ASSIGN                                                   !2, ~8
   62    12        ASSIGN                                                   !3, 0
         13      > JMP                                                      ->108
   64    14    >   FETCH_DIM_R                                      ~11     !0, !3
   66    15        CASE                                                     ~11, 'a'
         16      > JMPNZ                                                    ~12, ->98
   67    17    >   CASE                                                     ~11, 'b'
         18      > JMPNZ                                                    ~12, ->98
   68    19    >   CASE                                                     ~11, 'c'
         20      > JMPNZ                                                    ~12, ->98
   69    21    >   CASE                                                     ~11, 'd'
         22      > JMPNZ                                                    ~12, ->98
   70    23    >   CASE                                                     ~11, 'e'
         24      > JMPNZ                                                    ~12, ->98
   71    25    >   CASE                                                     ~11, 'f'
         26      > JMPNZ                                                    ~12, ->98
   72    27    >   CASE                                                     ~11, 'g'
         28      > JMPNZ                                                    ~12, ->98
   73    29    >   CASE                                                     ~11, 'h'
         30      > JMPNZ                                                    ~12, ->98
   74    31    >   CASE                                                     ~11, 'i'
         32      > JMPNZ                                                    ~12, ->98
   75    33    >   CASE                                                     ~11, 'j'
         34      > JMPNZ                                                    ~12, ->98
   76    35    >   CASE                                                     ~11, 'k'
         36      > JMPNZ                                                    ~12, ->98
   77    37    >   CASE                                                     ~11, 'l'
         38      > JMPNZ                                                    ~12, ->98
   78    39    >   CASE                                                     ~11, 'm'
         40      > JMPNZ                                                    ~12, ->98
   79    41    >   CASE                                                     ~11, 'n'
         42      > JMPNZ                                                    ~12, ->98
   80    43    >   CASE                                                     ~11, 'o'
         44      > JMPNZ                                                    ~12, ->98
   81    45    >   CASE                                                     ~11, 'p'
         46      > JMPNZ                                                    ~12, ->98
   82    47    >   CASE                                                     ~11, 'q'
         48      > JMPNZ                                                    ~12, ->98
   83    49    >   CASE                                                     ~11, 'r'
         50      > JMPNZ                                                    ~12, ->98
   84    51    >   CASE                                                     ~11, 's'
         52      > JMPNZ                                                    ~12, ->98
   85    53    >   CASE                                                     ~11, 't'
         54      > JMPNZ                                                    ~12, ->98
   86    55    >   CASE                                                     ~11, 'u'
         56      > JMPNZ                                                    ~12, ->98
   87    57    >   CASE                                                     ~11, 'v'
         58      > JMPNZ                                                    ~12, ->98
   88    59    >   CASE                                                     ~11, 'w'
         60      > JMPNZ                                                    ~12, ->98
   89    61    >   CASE                                                     ~11, 'x'
         62      > JMPNZ                                                    ~12, ->98
   90    63    >   CASE                                                     ~11, 'y'
         64      > JMPNZ                                                    ~12, ->98
   91    65    >   CASE                                                     ~11, 'z'
         66      > JMPNZ                                                    ~12, ->98
   92    67    >   CASE                                                     ~11, '0'
         68      > JMPNZ                                                    ~12, ->98
   93    69    >   CASE                                                     ~11, '1'
         70      > JMPNZ                                                    ~12, ->98
   94    71    >   CASE                                                     ~11, '2'
         72      > JMPNZ                                                    ~12, ->98
   95    73    >   CASE                                                     ~11, '3'
         74      > JMPNZ                                                    ~12, ->98
   96    75    >   CASE                                                     ~11, '4'
         76      > JMPNZ                                                    ~12, ->98
   97    77    >   CASE                                                     ~11, '5'
         78      > JMPNZ                                                    ~12, ->98
   98    79    >   CASE                                                     ~11, '6'
         80      > JMPNZ                                                    ~12, ->98
   99    81    >   CASE                                                     ~11, '7'
         82      > JMPNZ                                                    ~12, ->98
  100    83    >   CASE                                                     ~11, '8'
         84      > JMPNZ                                                    ~12, ->98
  101    85    >   CASE                                                     ~11, '9'
         86      > JMPNZ                                                    ~12, ->98
  102    87    >   CASE                                                     ~11, '_'
         88      > JMPNZ                                                    ~12, ->98
  103    89    >   CASE                                                     ~11, '-'
         90      > JMPNZ                                                    ~12, ->98
  104    91    >   CASE                                                     ~11, '%2F'
         92      > JMPNZ                                                    ~12, ->98
  109    93    >   CASE                                                     ~11, '%5C'
         94      > JMPNZ                                                    ~12, ->101
  114    95    >   CASE                                                     ~11, '+'
         96      > JMPNZ                                                    ~12, ->103
         97    > > JMP                                                      ->105
  105    98    >   FETCH_DIM_R                                      ~13     !0, !3
         99        ASSIGN_OP                                     8          !1, ~13
  106   100      > JMP                                                      ->106
  110   101    >   ASSIGN_OP                                     8          !1, '%2F'
  111   102      > JMP                                                      ->106
  115   103    >   ASSIGN_OP                                     8          !1, '_'
  116   104      > JMP                                                      ->106
  119   105    > > JMP                                                      ->106
        106    >   FREE                                                     ~11
   62   107        PRE_INC                                                  !3
        108    >   IS_SMALLER                                               !3, !2
        109      > JMPNZ                                                    ~18, ->14
  123   110    > > RETURN                                                   !1
  124   111*     > RETURN                                                   null

End of function cleanpagepath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.92 ms | 1416 KiB | 23 Q