3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = 'Happy^ hour^ / is fun //'; function filenameEncode($possible_filename){ $fngood = str_replace(array('^',';','/',':'), array('^^',';;','^',';'), $possible_filename); return $fngood; } function filenameDecode($possible_filename){ //all single carets need to be replaced with slashes $possible_filename = preg_replace('/([^\^])(\^)([^\^])/im', '$1/$3', $possible_filename); //all semi-colons need to be replaced with colons $possible_filename = preg_replace('/([^;])(;)([^;])/im', '$1:$3', $possible_filename); $fngood = str_replace(array('^',';'), array('/',':'), $possible_filename); return $possible_filename; } echo 's: '.$s."\n"; $t = filenameEncode($s); $u = filenameDecode($t); echo 't: '.$t."\n"; echo 'u: '.$u."\n"; if ($s === $u){ echo 'test passed'; }else{ echo 'test failed'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8g8Uc
function name:  (null)
number of ops:  24
compiled vars:  !0 = $s, !1 = $t, !2 = $u
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Happy%5E+hour%5E+%2F+is+fun+%2F%2F'
   20     1        CONCAT                                           ~4      's%3A+', !0
          2        CONCAT                                           ~5      ~4, '%0A'
          3        ECHO                                                     ~5
   22     4        INIT_FCALL                                               'filenameencode'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !1, $6
   24     8        INIT_FCALL                                               'filenamedecode'
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $8      
         11        ASSIGN                                                   !2, $8
   26    12        CONCAT                                           ~10     't%3A+', !1
         13        CONCAT                                           ~11     ~10, '%0A'
         14        ECHO                                                     ~11
   27    15        CONCAT                                           ~12     'u%3A+', !2
         16        CONCAT                                           ~13     ~12, '%0A'
         17        ECHO                                                     ~13
   29    18        IS_IDENTICAL                                             !0, !2
         19      > JMPZ                                                     ~14, ->22
   30    20    >   ECHO                                                     'test+passed'
         21      > JMP                                                      ->23
   32    22    >   ECHO                                                     'test+failed'
   33    23    > > RETURN                                                   1

Function filenameencode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8g8Uc
function name:  filenameEncode
number of ops:  9
compiled vars:  !0 = $possible_filename, !1 = $fngood
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !1, $2
    7     7      > RETURN                                                   !1
    8     8*     > RETURN                                                   null

End of function filenameencode

Function filenamedecode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8g8Uc
function name:  filenameDecode
number of ops:  21
compiled vars:  !0 = $possible_filename, !1 = $fngood
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%28%5B%5E%5C%5E%5D%29%28%5C%5E%29%28%5B%5E%5C%5E%5D%29%2Fim'
          3        SEND_VAL                                                 '%241%2F%243'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   14     7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%2F%28%5B%5E%3B%5D%29%28%3B%29%28%5B%5E%3B%5D%29%2Fim'
          9        SEND_VAL                                                 '%241%3A%243'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $4      
         12        ASSIGN                                                   !0, $4
   15    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 <array>
         15        SEND_VAL                                                 <array>
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $6      
         18        ASSIGN                                                   !1, $6
   16    19      > RETURN                                                   !0
   17    20*     > RETURN                                                   null

End of function filenamedecode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.88 ms | 1394 KiB | 19 Q