3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists("str_ends_with")) { function str_ends_with($haystack, $needle) { return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle); } } $urls = [ "https://www.example.gov.us/directory_1/directory_2/directory_3/index.php", "https://www.example.gov.us/directory_1/directory_2/directory_3/index", "https://www.example.gov.us/directory_1/directory_2/directory_3/" ]; foreach ($urls as $url) { printf( "From %s, got '%s'%s", $url, str_ends_with($url, "/") ? "" : basename($url), PHP_EOL ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 6
filename:       /in/qQiOq
function name:  (null)
number of ops:  29
compiled vars:  !0 = $urls, !1 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'str_ends_with'
          2        DO_ICALL                                         $2      
          3        BOOL_NOT                                         ~3      $2
          4      > JMPZ                                                     ~3, ->6
    4     5    >   DECLARE_FUNCTION                                         'str_ends_with'
    9     6    >   ASSIGN                                                   !0, <array>
   15     7      > FE_RESET_R                                       $5      !0, ->27
          8    > > FE_FETCH_R                                               $5, !1, ->27
   16     9    >   INIT_FCALL                                               'printf'
   17    10        SEND_VAL                                                 'From+%25s%2C+got+%27%25s%27%25s'
   18    11        SEND_VAR                                                 !1
   19    12        INIT_FCALL                                               'str_ends_with'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 '%2F'
         15        DO_ICALL                                         $6      
         16      > JMPZ                                                     $6, ->19
         17    >   QM_ASSIGN                                        ~7      ''
         18      > JMP                                                      ->23
         19    >   INIT_FCALL                                               'basename'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $8      
         22        QM_ASSIGN                                        ~7      $8
         23    >   SEND_VAL                                                 ~7
   20    24        SEND_VAL                                                 '%0A'
   16    25        DO_ICALL                                                 
   15    26      > JMP                                                      ->8
         27    >   FE_FREE                                                  $5
   22    28      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qQiOq
function name:  str_ends_with
number of ops:  12
compiled vars:  !0 = $haystack, !1 = $needle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'strrpos'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        STRLEN                                           ~3      !0
          7        STRLEN                                           ~4      !1
          8        SUB                                              ~5      ~3, ~4
          9        IS_IDENTICAL                                     ~6      $2, ~5
         10      > RETURN                                                   ~6
    6    11*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.99 ms | 1007 KiB | 18 Q