3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySpl extends SplFileInfo { public function getExtension() { if (method_exists('SplFileInfo', 'getExtension')) { return parent::getExtension(); } $parts = explode('.', parent::getPathname()); if (count($parts) <= 1) { return ""; } return end($parts); } } foreach (array('foo.bar', 'baz.tar.gz', '/usr/bin/php', 'foo', '/foo/baz.php') as $file) { $spl = new MySpl($file); var_dump($spl->getExtension()); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 12
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/mIbjI
function name:  (null)
number of ops:  14
compiled vars:  !0 = $file, !1 = $spl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E > > FE_RESET_R                                       $2      <array>, ->12
          1    > > FE_FETCH_R                                               $2, !0, ->12
   22     2    >   NEW                                              $3      'MySpl'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   24     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !1, 'getExtension'
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   21    11      > JMP                                                      ->1
         12    >   FE_FREE                                                  $2
   25    13      > RETURN                                                   1

Class MySpl:
Function getextension:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mIbjI
function name:  getExtension
number of ops:  24
compiled vars:  !0 = $parts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'method_exists'
          1        SEND_VAL                                                 'SplFileInfo'
          2        SEND_VAL                                                 'getExtension'
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->8
    8     5    >   INIT_STATIC_METHOD_CALL                                  'getExtension'
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   11     8    >   INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '.'
         10        INIT_STATIC_METHOD_CALL                                  'getPathname'
         11        DO_FCALL                                      0  $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                         $4      
         14        ASSIGN                                                   !0, $4
   13    15        COUNT                                            ~6      !0
         16        IS_SMALLER_OR_EQUAL                                      ~6, 1
         17      > JMPZ                                                     ~7, ->19
   14    18    > > RETURN                                                   ''
   17    19    >   INIT_FCALL                                               'end'
         20        SEND_REF                                                 !0
         21        DO_ICALL                                         $8      
         22      > RETURN                                                   $8
   18    23*     > RETURN                                                   null

End of function getextension

End of class MySpl.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.68 ms | 1400 KiB | 21 Q