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."\n"; $t = filenameEncode($s); $u = filenameDecode($t); echo $t."\n"; echo $u."\n"; if ($s === $u){ echo 'test passed'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/k1q6V
function name:  (null)
number of ops:  19
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      !0, '%0A'
          2        ECHO                                                     ~4
   22     3        INIT_FCALL                                               'filenameencode'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   24     7        INIT_FCALL                                               'filenamedecode'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !2, $7
   26    11        CONCAT                                           ~9      !1, '%0A'
         12        ECHO                                                     ~9
   27    13        CONCAT                                           ~10     !2, '%0A'
         14        ECHO                                                     ~10
   29    15        IS_IDENTICAL                                             !0, !2
         16      > JMPZ                                                     ~11, ->18
   30    17    >   ECHO                                                     'test+passed'
   31    18    > > RETURN                                                   1

Function filenameencode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k1q6V
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/k1q6V
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:
164.41 ms | 1403 KiB | 19 Q