3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace NotGlobal; const PHP_URL_SCHEME = 0x001; const PHP_URL_USER = 0x002; const PHP_URL_PASS = 0x004; const PHP_URL_HOST = 0x008; const PHP_URL_PORT = 0x010; const PHP_URL_PATH = 0x020; const PHP_URL_QUERY = 0x040; const PHP_URL_FRAGMENT = 0x080; const PHP_URL_ALL = 0x0FF; const PHP_URL_REQUIRE_SCHEME = 0x100; const PHP_URL_DISALLOW_EMPTY_AUTHORITY = 0x200; function parse_url($url, $flags = PHP_URL_ALL) { static $map = [ PHP_URL_SCHEME => 'scheme', PHP_URL_USER => 'user', PHP_URL_PASS => 'pass', PHP_URL_HOST => 'host', PHP_URL_PORT => 'port', PHP_URL_PATH => 'path', PHP_URL_QUERY => 'query', PHP_URL_FRAGMENT => 'fragment', ]; static $pattern = <<<EXPR ! ^ (?: (?P<scheme> [a-z][a-z0-9+.\-]* ) [:] )? (?: (?<hasauthority> [/][/] ) (?: (?P<user> [^:@/\s]+ ) (?: [:] (?P<pass> [^:@/\s]+ ) )? [@] )? (?P<host> [^:/?#\s]* ) (?: [:] (?P<port> [0-9]+ ) )? (?= [/?#]|$ ) )? (?P<path> [^?#\s]+ )? (?: [?] (?P<query> [^#\s]+ ) )? (?: [#] (?P<fragment> \S+ ) )? $ !xi EXPR; if (!preg_match($pattern, trim($url), $matches)) { return 1; } if ($flags & PHP_URL_REQUIRE_SCHEME) { if (!isset($matches['scheme']) || $matches['scheme'] === '') { return 2; } } if ($flags & PHP_URL_DISALLOW_EMPTY_AUTHORITY) { if (isset($matches['hasauthority']) && $matches['hasauthority'] && (!isset($matches['host']) || $matches['host'] === '')) { return 3; } } // Default to all components, allowing the above flags // to be specified without specifying the components $flags = $flags & PHP_URL_ALL ?: PHP_URL_ALL; $result = []; foreach ($map as $flag => $component) { if (($flags & $flag) && isset($matches[$component]) && $matches[$component] !== '') { $result[$component] = $flag === PHP_URL_PORT ? (int) $matches[$component] : $matches[$component]; } } return count($result) === 1 ? end($result) : $result; } $url = 'http://foo:123454/test'; var_dump(parse_url($url, PHP_URL_PORT | PHP_URL_PATH));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VPPX1
function name:  (null)
number of ops:  23
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CONST                                            'NotGlobal%5CPHP_URL_SCHEME', 1
    6     1        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_USER', 2
    7     2        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_PASS', 4
    8     3        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_HOST', 8
    9     4        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_PORT', 16
   10     5        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_PATH', 32
   11     6        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_QUERY', 64
   12     7        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_FRAGMENT', 128
   13     8        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_ALL', 255
   15     9        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_REQUIRE_SCHEME', 256
   16    10        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_DISALLOW_EMPTY_AUTHORITY', 512
   82    11        ASSIGN                                                   !0, 'http%3A%2F%2Ffoo%3A123454%2Ftest'
   83    12        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cvar_dump'
         13        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cparse_url'
         14        SEND_VAR_EX                                              !0
         15        FETCH_CONSTANT                                   ~2      'NotGlobal%5CPHP_URL_PORT'
         16        FETCH_CONSTANT                                   ~3      'NotGlobal%5CPHP_URL_PATH'
         17        BW_OR                                            ~4      ~2, ~3
         18        SEND_VAL_EX                                              ~4
         19        DO_FCALL                                      0  $5      
         20        SEND_VAR_NO_REF_EX                                       $5
         21        DO_FCALL                                      0          
         22      > RETURN                                                   1

Function notglobal%5Cparse_url:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
2 jumps found. (Code = 47) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 43
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 41
Branch analysis from position: 34
2 jumps found. (Code = 47) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 74
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 74
Branch analysis from position: 52
2 jumps found. (Code = 46) Position 1 = 55, Position 2 = 57
Branch analysis from position: 55
2 jumps found. (Code = 46) Position 1 = 58, Position 2 = 61
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 73
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 69
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 73
Branch analysis from position: 61
Branch analysis from position: 57
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 85
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
Branch analysis from position: 40
Branch analysis from position: 41
Branch analysis from position: 33
Branch analysis from position: 43
Branch analysis from position: 24
Branch analysis from position: 26
filename:       /in/VPPX1
function name:  NotGlobal\parse_url
number of ops:  88
compiled vars:  !0 = $url, !1 = $flags, !2 = $map, !3 = $pattern, !4 = $matches, !5 = $result, !6 = $component, !7 = $flag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
   20     2        BIND_STATIC                                              !2
   30     3        BIND_STATIC                                              !3
   52     4        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cpreg_match'
          5        SEND_VAR_EX                                              !3
          6        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Ctrim'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $8      
          9        SEND_VAR_NO_REF_EX                                       $8
         10        SEND_VAR_EX                                              !4
         11        DO_FCALL                                      0  $9      
         12        BOOL_NOT                                         ~10     $9
         13      > JMPZ                                                     ~10, ->15
   53    14    > > RETURN                                                   1
   56    15    >   FETCH_CONSTANT                                   ~11     'NotGlobal%5CPHP_URL_REQUIRE_SCHEME'
         16        BW_AND                                           ~12     !1, ~11
         17      > JMPZ                                                     ~12, ->26
   57    18    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !4, 'scheme'
         19        BOOL_NOT                                         ~14     ~13
         20      > JMPNZ_EX                                         ~14     ~14, ->24
         21    >   FETCH_DIM_R                                      ~15     !4, 'scheme'
         22        IS_IDENTICAL                                     ~16     ~15, ''
         23        BOOL                                             ~14     ~16
         24    > > JMPZ                                                     ~14, ->26
   58    25    > > RETURN                                                   2
   62    26    >   FETCH_CONSTANT                                   ~17     'NotGlobal%5CPHP_URL_DISALLOW_EMPTY_AUTHORITY'
         27        BW_AND                                           ~18     !1, ~17
         28      > JMPZ                                                     ~18, ->43
   63    29    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !4, 'hasauthority'
         30      > JMPZ_EX                                          ~19     ~19, ->33
         31    >   FETCH_DIM_R                                      ~20     !4, 'hasauthority'
         32        BOOL                                             ~19     ~20
         33    > > JMPZ_EX                                          ~19     ~19, ->41
         34    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~21     !4, 'host'
         35        BOOL_NOT                                         ~22     ~21
         36      > JMPNZ_EX                                         ~22     ~22, ->40
         37    >   FETCH_DIM_R                                      ~23     !4, 'host'
         38        IS_IDENTICAL                                     ~24     ~23, ''
         39        BOOL                                             ~22     ~24
         40    >   BOOL                                             ~19     ~22
         41    > > JMPZ                                                     ~19, ->43
   64    42    > > RETURN                                                   3
   70    43    >   FETCH_CONSTANT                                   ~25     'NotGlobal%5CPHP_URL_ALL'
         44        BW_AND                                           ~26     !1, ~25
         45        JMP_SET                                          ~27     ~26, ->48
         46        FETCH_CONSTANT                                   ~28     'NotGlobal%5CPHP_URL_ALL'
         47        QM_ASSIGN                                        ~27     ~28
         48        ASSIGN                                                   !1, ~27
   72    49        ASSIGN                                                   !5, <array>
   73    50      > FE_RESET_R                                       $31     !2, ->74
         51    > > FE_FETCH_R                                       ~32     $31, !6, ->74
         52    >   ASSIGN                                                   !7, ~32
   74    53        BW_AND                                           ~34     !1, !7
         54      > JMPZ_EX                                          ~34     ~34, ->57
         55    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~35     !4, !6
         56        BOOL                                             ~34     ~35
         57    > > JMPZ_EX                                          ~34     ~34, ->61
         58    >   FETCH_DIM_R                                      ~36     !4, !6
         59        IS_NOT_IDENTICAL                                 ~37     ~36, ''
         60        BOOL                                             ~34     ~37
         61    > > JMPZ                                                     ~34, ->73
   75    62    >   FETCH_CONSTANT                                   ~39     'NotGlobal%5CPHP_URL_PORT'
         63        IS_IDENTICAL                                             !7, ~39
         64      > JMPZ                                                     ~40, ->69
         65    >   FETCH_DIM_R                                      ~41     !4, !6
         66        CAST                                          4  ~42     ~41
         67        QM_ASSIGN                                        ~43     ~42
         68      > JMP                                                      ->71
         69    >   FETCH_DIM_R                                      ~44     !4, !6
         70        QM_ASSIGN                                        ~43     ~44
         71    >   ASSIGN_DIM                                               !5, !6
         72        OP_DATA                                                  ~43
   73    73    > > JMP                                                      ->51
         74    >   FE_FREE                                                  $31
   79    75        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Ccount'
         76        SEND_VAR_EX                                              !5
         77        DO_FCALL                                      0  $45     
         78        IS_IDENTICAL                                             $45, 1
         79      > JMPZ                                                     ~46, ->85
         80    >   INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cend'
         81        SEND_VAR_EX                                              !5
         82        DO_FCALL                                      0  $47     
         83        QM_ASSIGN                                        ~48     $47
         84      > JMP                                                      ->86
         85    >   QM_ASSIGN                                        ~48     !5
         86    > > RETURN                                                   ~48
   80    87*     > RETURN                                                   null

End of function notglobal%5Cparse_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
196.03 ms | 1400 KiB | 25 Q