3v4l.org

run code in 300+ PHP versions simultaneously
<?php function unicode2utf8($c){ $output=""; if($c < 0x80) { return chr($c); } else if($c < 0x800) { return chr( 0xc0 | ($c >> 6) ).chr( 0x80 | ($c & 0x3f) ); } else if($c < 0x10000) { return chr( 0xe0 | ($c >> 12) ).chr( 0x80 | (($c >> 6) & 0x3f) ).chr( 0x80 | ($c & 0x3f) ); } else if($c < 0x200000) { return chr(0xf0 | ($c >> 18)).chr(0x80 | (($c >> 12) & 0x3f)).chr(0x80 | (($c >> 6) & 0x3f)).chr(0x80 | ($c & 0x3f)); } return false; } function sanitizeFileName( $name ) { $invalidCharacters = array("\x2f", "\x22", "\x2a", "\x3a", "\x3c", "\x3e", "\x3f", "\x5c", "\x7f"); $name = str_replace($invalidCharacters, '', $name); $name = preg_replace('$[\x{0000}-\x{001F}]$u', '', $name); return $name; } $str = "blablabla ǹéñ~# - ".unicode2utf8(0xE001).' - '.unicode2utf8(0xFDD3).' - '.unicode2utf8(0xFD00); var_dump($str); var_dump(sanitizeFileName($str));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9GmJM
function name:  (null)
number of ops:  25
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'unicode2utf8'
          1        SEND_VAL                                                 57345
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      'blablabla+%C7%B9%C3%A9%C3%B1%7E%23+-+', $1
          4        CONCAT                                           ~3      ~2, '+-+'
          5        INIT_FCALL                                               'unicode2utf8'
          6        SEND_VAL                                                 64979
          7        DO_FCALL                                      0  $4      
          8        CONCAT                                           ~5      ~3, $4
          9        CONCAT                                           ~6      ~5, '+-+'
         10        INIT_FCALL                                               'unicode2utf8'
         11        SEND_VAL                                                 64768
         12        DO_FCALL                                      0  $7      
         13        CONCAT                                           ~8      ~6, $7
         14        ASSIGN                                                   !0, ~8
   33    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
   34    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'sanitizefilename'
         20        SEND_VAR                                                 !0
         21        DO_FCALL                                      0  $11     
         22        SEND_VAR                                                 $11
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function unicode2utf8:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 24
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 46
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 74
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9GmJM
function name:  unicode2utf8
number of ops:  76
compiled vars:  !0 = $c, !1 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, ''
    5     2        IS_SMALLER                                               !0, 128
          3      > JMPZ                                                     ~3, ->9
    7     4    >   INIT_FCALL                                               'chr'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7      > RETURN                                                   $4
          8*       JMP                                                      ->74
    9     9    >   IS_SMALLER                                               !0, 2048
         10      > JMPZ                                                     ~5, ->24
   11    11    >   INIT_FCALL                                               'chr'
         12        SR                                               ~6      !0, 6
         13        BW_OR                                            ~7      ~6, 192
         14        SEND_VAL                                                 ~7
         15        DO_ICALL                                         $8      
         16        INIT_FCALL                                               'chr'
         17        BW_AND                                           ~9      !0, 63
         18        BW_OR                                            ~10     ~9, 128
         19        SEND_VAL                                                 ~10
         20        DO_ICALL                                         $11     
         21        CONCAT                                           ~12     $8, $11
         22      > RETURN                                                   ~12
         23*       JMP                                                      ->74
   13    24    >   IS_SMALLER                                               !0, 65536
         25      > JMPZ                                                     ~13, ->46
   15    26    >   INIT_FCALL                                               'chr'
         27        SR                                               ~14     !0, 12
         28        BW_OR                                            ~15     ~14, 224
         29        SEND_VAL                                                 ~15
         30        DO_ICALL                                         $16     
         31        INIT_FCALL                                               'chr'
         32        SR                                               ~17     !0, 6
         33        BW_AND                                           ~18     ~17, 63
         34        BW_OR                                            ~19     ~18, 128
         35        SEND_VAL                                                 ~19
         36        DO_ICALL                                         $20     
         37        CONCAT                                           ~21     $16, $20
         38        INIT_FCALL                                               'chr'
         39        BW_AND                                           ~22     !0, 63
         40        BW_OR                                            ~23     ~22, 128
         41        SEND_VAL                                                 ~23
         42        DO_ICALL                                         $24     
         43        CONCAT                                           ~25     ~21, $24
         44      > RETURN                                                   ~25
         45*       JMP                                                      ->74
   17    46    >   IS_SMALLER                                               !0, 2097152
         47      > JMPZ                                                     ~26, ->74
   19    48    >   INIT_FCALL                                               'chr'
         49        SR                                               ~27     !0, 18
         50        BW_OR                                            ~28     ~27, 240
         51        SEND_VAL                                                 ~28
         52        DO_ICALL                                         $29     
         53        INIT_FCALL                                               'chr'
         54        SR                                               ~30     !0, 12
         55        BW_AND                                           ~31     ~30, 63
         56        BW_OR                                            ~32     ~31, 128
         57        SEND_VAL                                                 ~32
         58        DO_ICALL                                         $33     
         59        CONCAT                                           ~34     $29, $33
         60        INIT_FCALL                                               'chr'
         61        SR                                               ~35     !0, 6
         62        BW_AND                                           ~36     ~35, 63
         63        BW_OR                                            ~37     ~36, 128
         64        SEND_VAL                                                 ~37
         65        DO_ICALL                                         $38     
         66        CONCAT                                           ~39     ~34, $38
         67        INIT_FCALL                                               'chr'
         68        BW_AND                                           ~40     !0, 63
         69        BW_OR                                            ~41     ~40, 128
         70        SEND_VAL                                                 ~41
         71        DO_ICALL                                         $42     
         72        CONCAT                                           ~43     ~39, $42
         73      > RETURN                                                   ~43
   21    74    > > RETURN                                                   <false>
   22    75*     > RETURN                                                   null

End of function unicode2utf8

Function sanitizefilename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9GmJM
function name:  sanitizeFileName
number of ops:  16
compiled vars:  !0 = $name, !1 = $invalidCharacters
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        ASSIGN                                                   !1, <array>
   26     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
   27     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%24%5B%5Cx%7B0000%7D-%5Cx%7B001F%7D%5D%24u'
         10        SEND_VAL                                                 ''
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
   29    14      > RETURN                                                   !0
   30    15*     > RETURN                                                   null

End of function sanitizefilename

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.35 ms | 1407 KiB | 25 Q