3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($check) { $rx = '_^(https?)://([^:/?]+)(?::(\d+))?(?:(/[^?]+))?(?:\?(.*))?$_i'; echo "Test $check\n"; if (!preg_match($rx, $check, $m)) { echo "\tFAIL!\n"; } else { var_export($m); echo "\n"; } } test(''); test('http://www.example.com'); test('http://www.example.com:8080'); test('http://www.example.com/some/path'); test('http://www.example.com:8080/some/path'); test('http://www.example.com?queryString'); test('http://www.example.com/some/path?queryString'); test('http://www.example.com:8080/some/path?queryString');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcget
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'test'
          1        SEND_VAL                                                 ''
          2        DO_FCALL                                      0          
   13     3        INIT_FCALL                                               'test'
          4        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com'
          5        DO_FCALL                                      0          
   14     6        INIT_FCALL                                               'test'
          7        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com%3A8080'
          8        DO_FCALL                                      0          
   15     9        INIT_FCALL                                               'test'
         10        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com%2Fsome%2Fpath'
         11        DO_FCALL                                      0          
   16    12        INIT_FCALL                                               'test'
         13        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com%3A8080%2Fsome%2Fpath'
         14        DO_FCALL                                      0          
   17    15        INIT_FCALL                                               'test'
         16        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com%3FqueryString'
         17        DO_FCALL                                      0          
   18    18        INIT_FCALL                                               'test'
         19        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com%2Fsome%2Fpath%3FqueryString'
         20        DO_FCALL                                      0          
   19    21        INIT_FCALL                                               'test'
         22        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com%3A8080%2Fsome%2Fpath%3FqueryString'
         23        DO_FCALL                                      0          
         24      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcget
function name:  test
number of ops:  20
compiled vars:  !0 = $check, !1 = $rx, !2 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, '_%5E%28https%3F%29%3A%2F%2F%28%5B%5E%3A%2F%3F%5D%2B%29%28%3F%3A%3A%28%5Cd%2B%29%29%3F%28%3F%3A%28%2F%5B%5E%3F%5D%2B%29%29%3F%28%3F%3A%5C%3F%28.%2A%29%29%3F%24_i'
    4     2        ROPE_INIT                                     3  ~5      'Test+'
          3        ROPE_ADD                                      1  ~5      ~5, !0
          4        ROPE_END                                      2  ~4      ~5, '%0A'
          5        ECHO                                                     ~4
    5     6        INIT_FCALL                                               'preg_match'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !0
          9        SEND_REF                                                 !2
         10        DO_ICALL                                         $7      
         11        BOOL_NOT                                         ~8      $7
         12      > JMPZ                                                     ~8, ->15
    6    13    >   ECHO                                                     '%09FAIL%21%0A'
         14      > JMP                                                      ->19
    8    15    >   INIT_FCALL                                               'var_export'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
    9    18        ECHO                                                     '%0A'
   11    19    > > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.27 ms | 1403 KiB | 25 Q