3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gs_basename($filename) { if(strpos($filename,'/') !== false){ $baseDir=dirname($filename); $basename=str_replace($baseDir,'',$filename); $basename=str_replace('/','',$basename); } else { $basename=$filename; } return $basename; } //"/dd/ww/cc/中文.test" $b=basename('/dd/ww/cc/中文.test'); echo 1 . $b.''; // will print '.test' echo ''; $c=gs_basename('/dd/ww/cc/中文.test'); echo 2 . $c; // 中文.test
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qKRig
function name:  (null)
number of ops:  15
compiled vars:  !0 = $b, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'basename'
          1        SEND_VAL                                                 '%2Fdd%2Fww%2Fcc%2F%E4%B8%AD%E6%96%87.test'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   18     4        CONCAT                                           ~4      '1', !0
          5        CONCAT                                           ~5      ~4, ''
          6        ECHO                                                     ~5
   19     7        ECHO                                                     ''
   20     8        INIT_FCALL                                               'gs_basename'
          9        SEND_VAL                                                 '%2Fdd%2Fww%2Fcc%2F%E4%B8%AD%E6%96%87.test'
         10        DO_FCALL                                      0  $6      
         11        ASSIGN                                                   !1, $6
   21    12        CONCAT                                           ~8      '2', !1
         13        ECHO                                                     ~8
         14      > RETURN                                                   1

Function gs_basename:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 24
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qKRig
function name:  gs_basename
number of ops:  27
compiled vars:  !0 = $filename, !1 = $baseDir, !2 = $basename
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%2F'
          4        DO_ICALL                                         $3      
          5        TYPE_CHECK                                  1018          $3
          6      > JMPZ                                                     ~4, ->24
    5     7    >   INIT_FCALL                                               'dirname'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !1, $5
    6    11        INIT_FCALL                                               'str_replace'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 ''
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !2, $7
    7    17        INIT_FCALL                                               'str_replace'
         18        SEND_VAL                                                 '%2F'
         19        SEND_VAL                                                 ''
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $9      
         22        ASSIGN                                                   !2, $9
         23      > JMP                                                      ->25
   10    24    >   ASSIGN                                                   !2, !0
   12    25    > > RETURN                                                   !2
   13    26*     > RETURN                                                   null

End of function gs_basename

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.8 ms | 1403 KiB | 22 Q