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'; //$eventid = intval(strpos($url,'/events/').); preg_match_all ('/^(\d)+/',$url,$matches); $arraylen = count($matches); for($x=0;$x<$arraylen;$x++){ echo $matches[$x][0]."\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 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 32
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 32
Branch analysis from position: 39
Branch analysis from position: 32
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
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/RCqTN
function name:  (null)
number of ops:  40
compiled vars:  !0 = $testlen, !1 = $url, !2 = $matches, !3 = $arraylen, !4 = $x
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  $5      
          4        BOOL_NOT                                         ~6      $5
          5      > JMPZ                                                     ~6, ->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                                              ~8      !0, -1
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                         $9      
         16        IS_IDENTICAL                                     ~10     $9, 0
         17        BOOL_NOT                                         ~11     ~10
         18      > JMPZ                                                     ~11, ->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'
   31    23        INIT_FCALL                                               'preg_match_all'
         24        SEND_VAL                                                 '%2F%5E%28%5Cd%29%2B%2F'
         25        SEND_VAR                                                 !1
         26        SEND_REF                                                 !2
         27        DO_ICALL                                                 
   32    28        COUNT                                            ~14     !2
         29        ASSIGN                                                   !3, ~14
   33    30        ASSIGN                                                   !4, 0
         31      > JMP                                                      ->37
   34    32    >   FETCH_DIM_R                                      ~17     !2, !4
         33        FETCH_DIM_R                                      ~18     ~17, 0
         34        CONCAT                                           ~19     ~18, '%0A'
         35        ECHO                                                     ~19
   33    36        PRE_INC                                                  !4
         37    >   IS_SMALLER                                               !4, !3
         38      > JMPNZ                                                    ~21, ->32
   35    39    > > 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/RCqTN
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:
155.15 ms | 1394 KiB | 18 Q