3v4l.org

run code in 500+ PHP versions simultaneously
<?php $urls = [ 'www.example.com/myurl.html?unwantedthngs#hastag', 'www.example.com/myurl.html' ]; foreach ($urls as $url) { var_export(['strtok: ', strtok($url, '?')]); echo "\n"; var_export(['strstr/true: ', strstr($url, '?', true)]); // not reliable echo "\n"; var_export(['explode/2: ', explode('?', $url, 2)[0]]); // limit alls func to stop searching after first encounter echo "\n"; var_export(['substr/strrpos: ', substr($url, 0, strrpos( $url, "?"))]); // not reliable; still not with strpos() echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 46
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 46
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
filename:       /in/fRNSk
function name:  (null)
number of ops:  48
compiled vars:  !0 = $urls, !1 = $url
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    8     1      > FE_RESET_R                                           $3      !0, ->46
          2    > > FE_FETCH_R                                                   $3, !1, ->46
    9     3    >   INIT_FCALL                                                   'var_export'
          4        INIT_ARRAY                                           ~4      'strtok%3A+'
          5        INIT_FCALL                                                   'strtok'
          6        SEND_VAR                                                     !1
          7        SEND_VAL                                                     '%3F'
          8        DO_ICALL                                             $5      
          9        ADD_ARRAY_ELEMENT                                    ~4      $5
         10        SEND_VAL                                                     ~4
         11        DO_ICALL                                                     
   10    12        ECHO                                                         '%0A'
   11    13        INIT_FCALL                                                   'var_export'
         14        INIT_ARRAY                                           ~7      'strstr%2Ftrue%3A+'
         15        FRAMELESS_ICALL_3                strstr              ~8      !1, '%3F'
         16        OP_DATA                                                      <true>
         17        ADD_ARRAY_ELEMENT                                    ~7      ~8
         18        SEND_VAL                                                     ~7
         19        DO_ICALL                                                     
   12    20        ECHO                                                         '%0A'
   13    21        INIT_FCALL                                                   'var_export'
         22        INIT_ARRAY                                           ~10     'explode%2F2%3A+'
         23        INIT_FCALL                                                   'explode'
         24        SEND_VAL                                                     '%3F'
         25        SEND_VAR                                                     !1
         26        SEND_VAL                                                     2
         27        DO_ICALL                                             $11     
         28        FETCH_DIM_R                                          ~12     $11, 0
         29        ADD_ARRAY_ELEMENT                                    ~10     ~12
         30        SEND_VAL                                                     ~10
         31        DO_ICALL                                                     
   14    32        ECHO                                                         '%0A'
   15    33        INIT_FCALL                                                   'var_export'
         34        INIT_ARRAY                                           ~14     'substr%2Fstrrpos%3A+'
         35        INIT_FCALL                                                   'strrpos'
         36        SEND_VAR                                                     !1
         37        SEND_VAL                                                     '%3F'
         38        DO_ICALL                                             $15     
         39        FRAMELESS_ICALL_3                substr              ~16     !1, 0
         40        OP_DATA                                                      $15
         41        ADD_ARRAY_ELEMENT                                    ~14     ~16
         42        SEND_VAL                                                     ~14
         43        DO_ICALL                                                     
   16    44        ECHO                                                         '%0A---%0A'
    8    45      > JMP                                                          ->2
         46    >   FE_FREE                                                      $3
   17    47      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
202.45 ms | 2289 KiB | 17 Q