3v4l.org

run code in 300+ PHP versions simultaneously
<?php $uri = parse_url('/wordpress/blog/page-2/?id=bla'); // remove last element $path = dirname($uri['path']); // incase you got query params if (!empty($uri['query'])) { $path .= '?'.$uri['query']; } // string(5) "/wordpress/blog?id=bla" var_dump($path);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/joJrF
function name:  (null)
number of ops:  19
compiled vars:  !0 = $uri, !1 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'parse_url'
          1        SEND_VAL                                                 '%2Fwordpress%2Fblog%2Fpage-2%2F%3Fid%3Dbla'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
    5     4        INIT_FCALL                                               'dirname'
          5        FETCH_DIM_R                                      ~4      !0, 'path'
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !1, $5
    8     9        ISSET_ISEMPTY_DIM_OBJ                         1  ~7      !0, 'query'
         10        BOOL_NOT                                         ~8      ~7
         11      > JMPZ                                                     ~8, ->15
    9    12    >   FETCH_DIM_R                                      ~9      !0, 'query'
         13        CONCAT                                           ~10     '%3F', ~9
         14        ASSIGN_OP                                     8          !1, ~10
   13    15    >   INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.06 ms | 1399 KiB | 19 Q