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); $name = preg_replace('/[\x{0080}-\x{009F}]/u', '', $name); $name = preg_replace('/[\x{E000}-\x{F8FF}]/u', '', $name); $name = preg_replace('/[\x{FDD0}-\x{FDEF}]/u', '', $name); $name = preg_replace('/[\x{FFF0}-\x{FFFF}]/u', '', $name); return $name; } echo sanitizeFileName("blablabla ǹéñ~#>< - ".unicode2utf8(0xE001).' - '.unicode2utf8(0xFDD3).' - '.unicode2utf8(0xFD00));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aUVmm
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'sanitizefilename'
          1        INIT_FCALL                                               'unicode2utf8'
          2        SEND_VAL                                                 57345
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      'blablabla+%C7%B9%C3%A9%C3%B1%7E%23%3E%3C+-+', $0
          5        CONCAT                                           ~2      ~1, '+-+'
          6        INIT_FCALL                                               'unicode2utf8'
          7        SEND_VAL                                                 64979
          8        DO_FCALL                                      0  $3      
          9        CONCAT                                           ~4      ~2, $3
         10        CONCAT                                           ~5      ~4, '+-+'
         11        INIT_FCALL                                               'unicode2utf8'
         12        SEND_VAL                                                 64768
         13        DO_FCALL                                      0  $6      
         14        CONCAT                                           ~7      ~5, $6
         15        SEND_VAL                                                 ~7
         16        DO_FCALL                                      0  $8      
         17        ECHO                                                     $8
         18      > 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/aUVmm
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/aUVmm
function name:  sanitizeFileName
number of ops:  40
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                                                 '%2F%5B%5Cx%7B0000%7D-%5Cx%7B001F%7D%5D%2Fu'
         10        SEND_VAL                                                 ''
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
   28    14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%5B%5Cx%7B0080%7D-%5Cx%7B009F%7D%5D%2Fu'
         16        SEND_VAL                                                 ''
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !0, $7
   29    20        INIT_FCALL                                               'preg_replace'
         21        SEND_VAL                                                 '%2F%5B%5Cx%7BE000%7D-%5Cx%7BF8FF%7D%5D%2Fu'
         22        SEND_VAL                                                 ''
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $9      
         25        ASSIGN                                                   !0, $9
   30    26        INIT_FCALL                                               'preg_replace'
         27        SEND_VAL                                                 '%2F%5B%5Cx%7BFDD0%7D-%5Cx%7BFDEF%7D%5D%2Fu'
         28        SEND_VAL                                                 ''
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $11     
         31        ASSIGN                                                   !0, $11
   31    32        INIT_FCALL                                               'preg_replace'
         33        SEND_VAL                                                 '%2F%5B%5Cx%7BFFF0%7D-%5Cx%7BFFFF%7D%5D%2Fu'
         34        SEND_VAL                                                 ''
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $13     
         37        ASSIGN                                                   !0, $13
   33    38      > RETURN                                                   !0
   34    39*     > RETURN                                                   null

End of function sanitizefilename

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.88 ms | 956 KiB | 24 Q