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 = '!^(?:([a-z][a-z0-9+.\-]*):)?(?:(//)(?:([^:@/\s]+)(?::([^:@/\s]+))?@)?([^:/?#\s]*)(?::([0-9]+))?(?=[/?#]|$))?([^?#\s]+)?(?:\?([^#\s]+))?(?:#(\S+))?$!xi'; if (!preg_match($pattern, trim($url), $matches)) { return false; } print_r($matches); if ($flags & PHP_URL_REQUIRE_SCHEME) { if (!isset($matches['scheme']) || $matches['scheme'] === '') { return false; } } if ($flags & PHP_URL_DISALLOW_EMPTY_AUTHORITY) { if (isset($matches['hasauthority']) && $matches['hasauthority'] && (!isset($matches['host']) || $matches['host'] === '')) { return false; } } // 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; } parse_url('scheme://user:pass@host:12345/path?query#fragment');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5ls6Q
function name:  (null)
number of ops:  15
compiled vars:  none
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
   64    11        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cparse_url'
         12        SEND_VAL_EX                                              'scheme%3A%2F%2Fuser%3Apass%40host%3A12345%2Fpath%3Fquery%23fragment'
         13        DO_FCALL                                      0          
         14      > 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 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 47) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 46
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 44
Branch analysis from position: 37
2 jumps found. (Code = 47) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 46
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
2 jumps found. (Code = 77) Position 1 = 54, Position 2 = 77
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 77
Branch analysis from position: 55
2 jumps found. (Code = 46) Position 1 = 58, Position 2 = 60
Branch analysis from position: 58
2 jumps found. (Code = 46) Position 1 = 61, Position 2 = 64
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 76
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 72
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 76
Branch analysis from position: 64
Branch analysis from position: 60
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 88
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
Branch analysis from position: 43
Branch analysis from position: 44
Branch analysis from position: 36
Branch analysis from position: 46
Branch analysis from position: 27
Branch analysis from position: 29
filename:       /in/5ls6Q
function name:  NotGlobal\parse_url
number of ops:  91
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
   32     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
   33    14    > > RETURN                                                   <false>
   36    15    >   INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cprint_r'
         16        SEND_VAR_EX                                              !4
         17        DO_FCALL                                      0          
   38    18        FETCH_CONSTANT                                   ~12     'NotGlobal%5CPHP_URL_REQUIRE_SCHEME'
         19        BW_AND                                           ~13     !1, ~12
         20      > JMPZ                                                     ~13, ->29
   39    21    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !4, 'scheme'
         22        BOOL_NOT                                         ~15     ~14
         23      > JMPNZ_EX                                         ~15     ~15, ->27
         24    >   FETCH_DIM_R                                      ~16     !4, 'scheme'
         25        IS_IDENTICAL                                     ~17     ~16, ''
         26        BOOL                                             ~15     ~17
         27    > > JMPZ                                                     ~15, ->29
   40    28    > > RETURN                                                   <false>
   44    29    >   FETCH_CONSTANT                                   ~18     'NotGlobal%5CPHP_URL_DISALLOW_EMPTY_AUTHORITY'
         30        BW_AND                                           ~19     !1, ~18
         31      > JMPZ                                                     ~19, ->46
   45    32    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~20     !4, 'hasauthority'
         33      > JMPZ_EX                                          ~20     ~20, ->36
         34    >   FETCH_DIM_R                                      ~21     !4, 'hasauthority'
         35        BOOL                                             ~20     ~21
         36    > > JMPZ_EX                                          ~20     ~20, ->44
         37    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~22     !4, 'host'
         38        BOOL_NOT                                         ~23     ~22
         39      > JMPNZ_EX                                         ~23     ~23, ->43
         40    >   FETCH_DIM_R                                      ~24     !4, 'host'
         41        IS_IDENTICAL                                     ~25     ~24, ''
         42        BOOL                                             ~23     ~25
         43    >   BOOL                                             ~20     ~23
         44    > > JMPZ                                                     ~20, ->46
   46    45    > > RETURN                                                   <false>
   52    46    >   FETCH_CONSTANT                                   ~26     'NotGlobal%5CPHP_URL_ALL'
         47        BW_AND                                           ~27     !1, ~26
         48        JMP_SET                                          ~28     ~27, ->51
         49        FETCH_CONSTANT                                   ~29     'NotGlobal%5CPHP_URL_ALL'
         50        QM_ASSIGN                                        ~28     ~29
         51        ASSIGN                                                   !1, ~28
   54    52        ASSIGN                                                   !5, <array>
   55    53      > FE_RESET_R                                       $32     !2, ->77
         54    > > FE_FETCH_R                                       ~33     $32, !6, ->77
         55    >   ASSIGN                                                   !7, ~33
   56    56        BW_AND                                           ~35     !1, !7
         57      > JMPZ_EX                                          ~35     ~35, ->60
         58    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~36     !4, !6
         59        BOOL                                             ~35     ~36
         60    > > JMPZ_EX                                          ~35     ~35, ->64
         61    >   FETCH_DIM_R                                      ~37     !4, !6
         62        IS_NOT_IDENTICAL                                 ~38     ~37, ''
         63        BOOL                                             ~35     ~38
         64    > > JMPZ                                                     ~35, ->76
   57    65    >   FETCH_CONSTANT                                   ~40     'NotGlobal%5CPHP_URL_PORT'
         66        IS_IDENTICAL                                             !7, ~40
         67      > JMPZ                                                     ~41, ->72
         68    >   FETCH_DIM_R                                      ~42     !4, !6
         69        CAST                                          4  ~43     ~42
         70        QM_ASSIGN                                        ~44     ~43
         71      > JMP                                                      ->74
         72    >   FETCH_DIM_R                                      ~45     !4, !6
         73        QM_ASSIGN                                        ~44     ~45
         74    >   ASSIGN_DIM                                               !5, !6
         75        OP_DATA                                                  ~44
   55    76    > > JMP                                                      ->54
         77    >   FE_FREE                                                  $32
   61    78        INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Ccount'
         79        SEND_VAR_EX                                              !5
         80        DO_FCALL                                      0  $46     
         81        IS_IDENTICAL                                             $46, 1
         82      > JMPZ                                                     ~47, ->88
         83    >   INIT_NS_FCALL_BY_NAME                                    'NotGlobal%5Cend'
         84        SEND_VAR_EX                                              !5
         85        DO_FCALL                                      0  $48     
         86        QM_ASSIGN                                        ~49     $48
         87      > JMP                                                      ->89
         88    >   QM_ASSIGN                                        ~49     !5
         89    > > RETURN                                                   ~49
   62    90*     > RETURN                                                   null

End of function notglobal%5Cparse_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.53 ms | 1408 KiB | 25 Q