3v4l.org

run code in 300+ 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 = 52
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 52
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
filename:       /in/fRNSk
function name:  (null)
number of ops:  54
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, ->52
          2    > > FE_FETCH_R                                               $3, !1, ->52
    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        INIT_FCALL                                               'strstr'
         16        SEND_VAR                                                 !1
         17        SEND_VAL                                                 '%3F'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $8      
         20        ADD_ARRAY_ELEMENT                                ~7      $8
         21        SEND_VAL                                                 ~7
         22        DO_ICALL                                                 
   12    23        ECHO                                                     '%0A'
   13    24        INIT_FCALL                                               'var_export'
         25        INIT_ARRAY                                       ~10     'explode%2F2%3A+'
         26        INIT_FCALL                                               'explode'
         27        SEND_VAL                                                 '%3F'
         28        SEND_VAR                                                 !1
         29        SEND_VAL                                                 2
         30        DO_ICALL                                         $11     
         31        FETCH_DIM_R                                      ~12     $11, 0
         32        ADD_ARRAY_ELEMENT                                ~10     ~12
         33        SEND_VAL                                                 ~10
         34        DO_ICALL                                                 
   14    35        ECHO                                                     '%0A'
   15    36        INIT_FCALL                                               'var_export'
         37        INIT_ARRAY                                       ~14     'substr%2Fstrrpos%3A+'
         38        INIT_FCALL                                               'substr'
         39        SEND_VAR                                                 !1
         40        SEND_VAL                                                 0
         41        INIT_FCALL                                               'strrpos'
         42        SEND_VAR                                                 !1
         43        SEND_VAL                                                 '%3F'
         44        DO_ICALL                                         $15     
         45        SEND_VAR                                                 $15
         46        DO_ICALL                                         $16     
         47        ADD_ARRAY_ELEMENT                                ~14     $16
         48        SEND_VAL                                                 ~14
         49        DO_ICALL                                                 
   16    50        ECHO                                                     '%0A---%0A'
    8    51      > JMP                                                      ->2
         52    >   FE_FREE                                                  $3
   17    53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.21 ms | 1463 KiB | 19 Q