3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = <<<REGEXP ! ^ (?P<scheme> [a-z][a-z0-9+.\-]* ) [:] # scheme is mandatory, and followed by a : (?: [/][/] # // indicates that this component is the authority (?: (?P<user> [^:@/]+ ) (?: [:] (?P<pass> [^:@/]+ ) )? [@] )? # auth details are optional (?P<host> [^:/]* ) # host is mandatory. Technically it should be at least 1 char, but PHP has # internal schemes that violate this rule and as much as I dislike it, I # feel that we should pass this (?: [:] (?P<port> [0-9]+ ) )? # port is simply a sequence of decimal digits (?= [/?#]|$ ) # path must be missing or begin with / if authority is present )? (?P<path> [^?#]+ )? # path is everything up to the query/fragment (?: [?] (?P<query> [^#]+ ) )? # query is optional (?: [#] (?P<fragment> .+ ) )? # fragment is optional $ !xi REGEXP; $url = 'http://foo.com/test?thing=stuff#fragment'; preg_match($pattern, $url, $matches); print_r($matches);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6pbfn
function name:  (null)
number of ops:  11
compiled vars:  !0 = $pattern, !1 = $url, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%21%0A++%5E%0A++++%28%3FP%3Cscheme%3E+%5Ba-z%5D%5Ba-z0-9%2B.%5C-%5D%2A+%29+%5B%3A%5D+%23+scheme+is+mandatory%2C+and+followed+by+a+%3A%0A%0A++++%28%3F%3A+%5B%2F%5D%5B%2F%5D+++++++++++++++++++++++++++%23+%2F%2F+indicates+that+this+component+is+the+authority%0A++++++%28%3F%3A%0A++++++++%28%3FP%3Cuser%3E+%5B%5E%3A%40%2F%5D%2B+%29%0A++++++++%28%3F%3A+%5B%3A%5D+%28%3FP%3Cpass%3E+%5B%5E%3A%40%2F%5D%2B+%29+%29%3F%0A++++++++%5B%40%5D%0A++++++%29%3F+++++++++++++++++++++++++++++++++%23+auth+details+are+optional%0A%0A++++++%28%3FP%3Chost%3E+%5B%5E%3A%2F%5D%2A+%29+++++++++++++++++%23+host+is+mandatory.+Technically+it+should+be+at+least+1+char%2C+but+PHP+has%0A+++++++++++++++++++++++++++++++++++++++++%23+internal+schemes+that+violate+this+rule+and+as+much+as+I+dislike+it%2C+I%0A+++++++++++++++++++++++++++++++++++++++++%23+feel+that+we+should+pass+this%0A%0A++++++%28%3F%3A+%5B%3A%5D+%28%3FP%3Cport%3E+%5B0-9%5D%2B+%29+%29%3F++++++%23+port+is+simply+a+sequence+of+decimal+digits%0A%0A++++++%28%3F%3D+%5B%2F%3F%23%5D%7C%24+%29++++++++++++++++++++++%23+path+must+be+missing+or+begin+with+%2F+if+authority+is+present%0A++++%29%3F%0A%0A++++%28%3FP%3Cpath%3E+%5B%5E%3F%23%5D%2B+%29%3F++++++++++++++++++%23+path+is+everything+up+to+the+query%2Ffragment%0A%0A++++%28%3F%3A+%5B%3F%5D+%28%3FP%3Cquery%3E+%5B%5E%23%5D%2B+%29+%29%3F++++++++++%23+query+is+optional%0A%0A++++%28%3F%3A+%5B%23%5D+%28%3FP%3Cfragment%3E+.%2B+%29+%29%3F++++++++++%23+fragment+is+optional%0A++%24%0A%21xi'
   33     1        ASSIGN                                                   !1, 'http%3A%2F%2Ffoo.com%2Ftest%3Fthing%3Dstuff%23fragment'
   36     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
   37     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.12 ms | 1395 KiB | 17 Q