3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getExt($filename) { // if(!is_file($filename)) return ''; $n = strlen($filename); // if($n<2) return ''; $non_ext = ''; $ext = ''; for($i=$n;$i--;$i>=1) { $c = $filename[$i]; if($c==='.') { $ext = '.'.$non_ext.$ext; $non_ext = ''; }else $non_ext = $c.$non_ext; } return $ext; } $filename = "asdfasdfasd.tar.gz"; $ext = getExt($filename); var_dump($ext); Var_dump(explode(".", $filename, 2)[1]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rj1g
function name:  (null)
number of ops:  18
compiled vars:  !0 = $filename, !1 = $ext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, 'asdfasdfasd.tar.gz'
   21     1        INIT_FCALL                                               'getext'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   22     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   24     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '.'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 2
         13        DO_ICALL                                         $6      
         14        FETCH_DIM_R                                      ~7      $6, 1
         15        SEND_VAL                                                 ~7
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function getext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
Branch analysis from position: 7
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
Branch analysis from position: 7
filename:       /in/3rj1g
function name:  getExt
number of ops:  24
compiled vars:  !0 = $filename, !1 = $n, !2 = $non_ext, !3 = $ext, !4 = $i, !5 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    6     1        STRLEN                                           ~6      !0
          2        ASSIGN                                                   !1, ~6
    8     3        ASSIGN                                                   !2, ''
    9     4        ASSIGN                                                   !3, ''
   10     5        ASSIGN                                                   !4, !1
          6      > JMP                                                      ->20
   11     7    >   FETCH_DIM_R                                      ~11     !0, !4
          8        ASSIGN                                                   !5, ~11
   12     9        IS_IDENTICAL                                             !5, '.'
         10      > JMPZ                                                     ~13, ->16
   13    11    >   CONCAT                                           ~14     '.', !2
         12        CONCAT                                           ~15     ~14, !3
         13        ASSIGN                                                   !3, ~15
   14    14        ASSIGN                                                   !2, ''
         15      > JMP                                                      ->18
   16    16    >   CONCAT                                           ~18     !5, !2
         17        ASSIGN                                                   !2, ~18
   10    18    >   IS_SMALLER_OR_EQUAL                              ~20     1, !4
         19        FREE                                                     ~20
         20    >   POST_DEC                                         ~21     !4
         21      > JMPNZ                                                    ~21, ->7
   18    22    > > RETURN                                                   !3
   19    23*     > RETURN                                                   null

End of function getext

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
192.65 ms | 1403 KiB | 18 Q