3v4l.org

run code in 500+ PHP versions simultaneously
<?php $urls = ['document/âne', 'ドキュメント/ウィスキー', '/документ/водка', '/etc/ôöœt', '/etc/', 'etc/fstab', 'etc/', '/fstab', 'fstab']; $format = "%-25s %-20s %s\n"; printf($format, '$url', 'basename($url)', 'substr(strrchr("/$url", "/"), 1)'); echo str_repeat('-', 80), PHP_EOL; foreach ($urls as $url) { printf($format, $url, fix_offset($url) .basename($url), fix_offset(basename($url)).substr(strrchr("/$url", '/'), 1)); } function fix_offset($str) { return str_repeat(' ', strlen($str) - mb_strlen($str)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 44
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 44
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/DlOg4
function name:  (null)
number of ops:  46
compiled vars:  !0 = $urls, !1 = $format, !2 = $url
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, '%25-25s+%25-20s+%25s%0A'
    6     2        INIT_FCALL                                                   'printf'
          3        SEND_VAR                                                     !1
          4        SEND_VAL                                                     '%24url'
          5        SEND_VAL                                                     'basename%28%24url%29'
          6        SEND_VAL                                                     'substr%28strrchr%28%22%2F%24url%22%2C+%22%2F%22%29%2C+1%29'
          7        DO_ICALL                                                     
    7     8        INIT_FCALL                                                   'str_repeat'
          9        SEND_VAL                                                     '-'
         10        SEND_VAL                                                     80
         11        DO_ICALL                                             $6      
         12        ECHO                                                         $6
         13        ECHO                                                         '%0A'
    9    14      > FE_RESET_R                                           $7      !0, ->44
         15    > > FE_FETCH_R                                                   $7, !2, ->44
   10    16    >   INIT_FCALL                                                   'printf'
         17        SEND_VAR                                                     !1
         18        SEND_VAR                                                     !2
         19        INIT_FCALL_BY_NAME                                           'fix_offset'
         20        SEND_VAR_EX                                                  !2
         21        DO_FCALL                                          0  $8      
         22        INIT_FCALL                                                   'basename'
         23        SEND_VAR                                                     !2
         24        DO_ICALL                                             $9      
         25        CONCAT                                               ~10     $8, $9
         26        SEND_VAL                                                     ~10
         27        INIT_FCALL_BY_NAME                                           'fix_offset'
         28        INIT_FCALL                                                   'basename'
         29        SEND_VAR                                                     !2
         30        DO_ICALL                                             $11     
         31        SEND_VAR_NO_REF_EX                                           $11
         32        DO_FCALL                                          0  $12     
         33        INIT_FCALL                                                   'strrchr'
         34        NOP                                                          
         35        FAST_CONCAT                                          ~13     '%2F', !2
         36        SEND_VAL                                                     ~13
         37        SEND_VAL                                                     '%2F'
         38        DO_ICALL                                             $14     
         39        FRAMELESS_ICALL_2                substr              ~15     $14, 1
         40        CONCAT                                               ~16     $12, ~15
         41        SEND_VAL                                                     ~16
         42        DO_ICALL                                                     
    9    43      > JMP                                                          ->15
         44    >   FE_FREE                                                      $7
   15    45      > RETURN                                                       1

Function fix_offset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DlOg4
function name:  fix_offset
number of ops:  12
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   14     1        INIT_FCALL                                                   'str_repeat'
          2        SEND_VAL                                                     '+'
          3        STRLEN                                               ~1      !0
          4        INIT_FCALL                                                   'mb_strlen'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $2      
          7        SUB                                                  ~3      ~1, $2
          8        SEND_VAL                                                     ~3
          9        DO_ICALL                                             $4      
         10      > RETURN                                                       $4
   15    11*     > RETURN                                                       null

End of function fix_offset

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
195.91 ms | 1587 KiB | 18 Q