3v4l.org

run code in 300+ PHP versions simultaneously
<?php function endswith($string, $test) { $strlen = strlen($string); $testlen = strlen($test); if ($testlen > $strlen) return false; return substr_compare($string, $test, -$testlen) === 0; } if(false == endswith('http://localhost/events/10','/events/')){ echo "true\n"; } else{ echo "false\n"; } $testlen = strlen('/bob/'); if(false == (substr_compare('http://localhost/events/10','/events/',-$testlen)===0)){ echo "true\n"; } else{ echo "false\n"; } $url = 'http://192.168.1.0/events/10'; preg_match_all('^\d+^',$url,$matches,PREG_PATTERN_ORDER); $arraylen = count($matches); for($x=0;$x<$arraylen;$x++){ $array3len = count($matches[$x]); for($z=0;$z<$array3len;$z++){ echo $matches[$x][$z]."\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 33
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 38
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 33
Branch analysis from position: 48
Branch analysis from position: 33
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 38
Branch analysis from position: 45
Branch analysis from position: 38
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
Branch analysis from position: 21
filename:       /in/MWY2R
function name:  (null)
number of ops:  49
compiled vars:  !0 = $testlen, !1 = $url, !2 = $matches, !3 = $arraylen, !4 = $x, !5 = $array3len, !6 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'endswith'
          1        SEND_VAL                                                 'http%3A%2F%2Flocalhost%2Fevents%2F10'
          2        SEND_VAL                                                 '%2Fevents%2F'
          3        DO_FCALL                                      0  $7      
          4        BOOL_NOT                                         ~8      $7
          5      > JMPZ                                                     ~8, ->8
   13     6    >   ECHO                                                     'true%0A'
          7      > JMP                                                      ->9
   16     8    >   ECHO                                                     'false%0A'
   19     9    >   ASSIGN                                                   !0, 5
   20    10        INIT_FCALL                                               'substr_compare'
         11        SEND_VAL                                                 'http%3A%2F%2Flocalhost%2Fevents%2F10'
         12        SEND_VAL                                                 '%2Fevents%2F'
         13        MUL                                              ~10     !0, -1
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                         $11     
         16        IS_IDENTICAL                                     ~12     $11, 0
         17        BOOL_NOT                                         ~13     ~12
         18      > JMPZ                                                     ~13, ->21
   21    19    >   ECHO                                                     'true%0A'
         20      > JMP                                                      ->22
   24    21    >   ECHO                                                     'false%0A'
   28    22    >   ASSIGN                                                   !1, 'http%3A%2F%2F192.168.1.0%2Fevents%2F10'
   30    23        INIT_FCALL                                               'preg_match_all'
         24        SEND_VAL                                                 '%5E%5Cd%2B%5E'
         25        SEND_VAR                                                 !1
         26        SEND_REF                                                 !2
         27        SEND_VAL                                                 1
         28        DO_ICALL                                                 
   31    29        COUNT                                            ~16     !2
         30        ASSIGN                                                   !3, ~16
   32    31        ASSIGN                                                   !4, 0
         32      > JMP                                                      ->46
   33    33    >   FETCH_DIM_R                                      ~19     !2, !4
         34        COUNT                                            ~20     ~19
         35        ASSIGN                                                   !5, ~20
   34    36        ASSIGN                                                   !6, 0
         37      > JMP                                                      ->43
   35    38    >   FETCH_DIM_R                                      ~23     !2, !4
         39        FETCH_DIM_R                                      ~24     ~23, !6
         40        CONCAT                                           ~25     ~24, '%0A'
         41        ECHO                                                     ~25
   34    42        PRE_INC                                                  !6
         43    >   IS_SMALLER                                               !6, !5
         44      > JMPNZ                                                    ~27, ->38
   32    45    >   PRE_INC                                                  !4
         46    >   IS_SMALLER                                               !4, !3
         47      > JMPNZ                                                    ~29, ->33
   37    48    > > RETURN                                                   1

Function endswith:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MWY2R
function name:  endswith
number of ops:  18
compiled vars:  !0 = $string, !1 = $test, !2 = $strlen, !3 = $testlen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        STRLEN                                           ~4      !0
          3        ASSIGN                                                   !2, ~4
    6     4        STRLEN                                           ~6      !1
          5        ASSIGN                                                   !3, ~6
    7     6        IS_SMALLER                                               !2, !3
          7      > JMPZ                                                     ~8, ->9
          8    > > RETURN                                                   <false>
    8     9    >   INIT_FCALL                                               'substr_compare'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        MUL                                              ~9      !3, -1
         13        SEND_VAL                                                 ~9
         14        DO_ICALL                                         $10     
         15        IS_IDENTICAL                                     ~11     $10, 0
         16      > RETURN                                                   ~11
    9    17*     > RETURN                                                   null

End of function endswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.29 ms | 1403 KiB | 18 Q