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_REQUIRE_SCHEME = 0x100; const PHP_URL_DISALLOW_EMPTY_AUTHORITY = 0x200; function parse_url($url, $flags = 0) { 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 = '! ^ (?: (?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'; 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 & 0xFF ?: 0xFF; $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:///test'; var_dump(parse_url($url, -1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tu28a
function name:  (null)
number of ops:  19
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
   14     8        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_REQUIRE_SCHEME', 256
   15     9        DECLARE_CONST                                            'NotGlobal%5CPHP_URL_DISALLOW_EMPTY_AUTHORITY', 512
   80    10        ASSIGN                                                   !0, 'http%3A%2F%2F%2Ftest'
   81    11        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cvar_dump'
         12        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cparse_url'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAL_EX                                              -1
         15        DO_FCALL                                      0  $2      
         16        SEND_VAR_NO_REF_EX                                       $2
         17        DO_FCALL                                      0          
         18      > 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 = 49, Position 2 = 72
Branch analysis from position: 49
2 jumps found. (Code = 78) Position 1 = 50, Position 2 = 72
Branch analysis from position: 50
2 jumps found. (Code = 46) Position 1 = 53, Position 2 = 55
Branch analysis from position: 53
2 jumps found. (Code = 46) Position 1 = 56, Position 2 = 59
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 71
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 67
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 71
Branch analysis from position: 59
Branch analysis from position: 55
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 83
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 83
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
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/tu28a
function name:  NotGlobal\parse_url
number of ops:  86
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
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   19     2        BIND_STATIC                                              !2
   29     3        BIND_STATIC                                              !3
   49     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
   50    14    > > RETURN                                                   1
   53    15    >   FETCH_CONSTANT                                   ~11     'NotGlobal%5CPHP_URL_REQUIRE_SCHEME'
         16        BW_AND                                           ~12     !1, ~11
         17      > JMPZ                                                     ~12, ->26
   54    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
   55    25    > > RETURN                                                   2
   59    26    >   FETCH_CONSTANT                                   ~17     'NotGlobal%5CPHP_URL_DISALLOW_EMPTY_AUTHORITY'
         27        BW_AND                                           ~18     !1, ~17
         28      > JMPZ                                                     ~18, ->43
   60    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
   61    42    > > RETURN                                                   3
   67    43    >   BW_AND                                           ~25     !1, 255
         44        JMP_SET                                          ~26     ~25, ->46
         45        QM_ASSIGN                                        ~26     255
         46        ASSIGN                                                   !1, ~26
   69    47        ASSIGN                                                   !5, <array>
   70    48      > FE_RESET_R                                       $29     !2, ->72
         49    > > FE_FETCH_R                                       ~30     $29, !6, ->72
         50    >   ASSIGN                                                   !7, ~30
   71    51        BW_AND                                           ~32     !1, !7
         52      > JMPZ_EX                                          ~32     ~32, ->55
         53    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~33     !4, !6
         54        BOOL                                             ~32     ~33
         55    > > JMPZ_EX                                          ~32     ~32, ->59
         56    >   FETCH_DIM_R                                      ~34     !4, !6
         57        IS_NOT_IDENTICAL                                 ~35     ~34, ''
         58        BOOL                                             ~32     ~35
         59    > > JMPZ                                                     ~32, ->71
   72    60    >   FETCH_CONSTANT                                   ~37     'NotGlobal%5CPHP_URL_PORT'
         61        IS_IDENTICAL                                             !7, ~37
         62      > JMPZ                                                     ~38, ->67
         63    >   FETCH_DIM_R                                      ~39     !4, !6
         64        CAST                                          4  ~40     ~39
         65        QM_ASSIGN                                        ~41     ~40
         66      > JMP                                                      ->69
         67    >   FETCH_DIM_R                                      ~42     !4, !6
         68        QM_ASSIGN                                        ~41     ~42
         69    >   ASSIGN_DIM                                               !5, !6
         70        OP_DATA                                                  ~41
   70    71    > > JMP                                                      ->49
         72    >   FE_FREE                                                  $29
   76    73        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Ccount'
         74        SEND_VAR_EX                                              !5
         75        DO_FCALL                                      0  $43     
         76        IS_IDENTICAL                                             $43, 1
         77      > JMPZ                                                     ~44, ->83
         78    >   INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cend'
         79        SEND_VAR_EX                                              !5
         80        DO_FCALL                                      0  $45     
         81        QM_ASSIGN                                        ~46     $45
         82      > JMP                                                      ->84
         83    >   QM_ASSIGN                                        ~46     !5
         84    > > RETURN                                                   ~46
   77    85*     > RETURN                                                   null

End of function notglobal%5Cparse_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.32 ms | 1408 KiB | 25 Q