3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $s = 'Happy^ hour^ / is fun //'; function filenameEncode($possible_filename){ $fngood = str_replace(array('^',';','/',':'), array('^^',';;','^',';'), $possible_filename); return $fngood; } function filenameDecode($possible_filename){ $fngood = str_replace(array('^',';','^^',';;'), array('^',';','/',':'), $possible_filename); return $fngood; } 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
Jump found. Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
Jump found. Position 1 = -2
Branch analysis from position: 20
filename:       /in/SnTqF
function name:  (null)
number of ops:  21
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'
   5     1        NOP                                                      
  10     2        NOP                                                      
  16     3        CONCAT                                           ~4      !0, '%0A'
         4        ECHO                                                     ~4
  18     5        INIT_FCALL                                               'filenameencode'
         6        SEND_VAR                                                 !0
         7        DO_FCALL                                      0  $5      
         8        ASSIGN                                                   !1, $5
  20     9        INIT_FCALL                                               'filenamedecode'
        10        SEND_VAR                                                 !1
        11        DO_FCALL                                      0  $7      
        12        ASSIGN                                                   !2, $7
  22    13        CONCAT                                           ~9      !1, '%0A'
        14        ECHO                                                     ~9
  23    15        CONCAT                                           ~10     !2, '%0A'
        16        ECHO                                                     ~10
  25    17        IS_IDENTICAL                                     ~11     !0, !2
        18      > JMPZ                                                     ~11, ->20
  26    19    >   ECHO                                                     'test+passed'
        20    > > RETURN                                                   1

Function filenameencode:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/SnTqF
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
Jump found. Position 1 = -2
filename:       /in/SnTqF
function name:  filenameDecode
number of ops:  9
compiled vars:  !0 = $possible_filename, !1 = $fngood
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  10     0  E >   RECV                                             !0      
  11     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
  12     7      > RETURN                                                   !1
  13     8*     > RETURN                                                   null

End of function filenamedecode

Generated using Vulcan Logic Dumper, using php 7.2.0