3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Url { private $user; private $pass; private $scheme; private $host; private $port; private $path; private $query = []; private $fragment; public function __construct($url){ $parts = parse_url($url); $parts = array_merge(array("user"=>"","pass"=>"", "scheme"=>"", "host"=>"", "port"=>"", "path"=>"", "query"=>"", "fragment"=>""), $parts); $this->user = $parts["user"]; $this->pass = $parts["pass"]; $this->scheme = $parts["scheme"]; $this->host = $parts["host"]; $this->port = $parts["port"]; $this->path = $parts["path"]; parse_str($parts["query"], $this->query); $this->fragment = $parts["fragment"]; } public function __get($property){ if (!property_exists($this, $property)){ throw new ErrorException("Property $property does not exist"); } return $this->$property; } public function __set($property, $value){ if (!property_exists($this, $property)){ throw new ErrorException("Property $property does not exist"); } $this->$property = $value; } public function setQueryParam($key, $value){ $this->query[$key] = $value; } public function getQueryParam($key, $default = false){ if (array_key_exists($key, $this->query)){ return $this->query["key"]; } else { return $default; } } public function __toString(){ return ($this->scheme?$this->scheme."://":""). ($this->user && $this->pass?$this->user.":".$this->pass."@":($this->user?$this->user."@":"")). ($this->host?$this->host:""). ($this->path?$this->path:""). ($this->query?"?".http_build_query($this->query):""). ($this->fragment?"#".$this->fragment:""); } } $url = new Url("http://test.com/test-one,two three?a=b#bla"); $url->setQueryParam("a", "blah"); $url->setQueryParam("foo", "bar"); $url->scheme = "https"; $url->user = "admin"; $url->pass = "topsecret"; echo (string)$url; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eSHD8
function name:  (null)
number of ops:  22
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'url'
   62     1        NEW                                              $1      'Url'
          2        SEND_VAL_EX                                              'http%3A%2F%2Ftest.com%2Ftest-one%2Ctwo+three%3Fa%3Db%23bla'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   63     5        INIT_METHOD_CALL                                         !0, 'setQueryParam'
          6        SEND_VAL_EX                                              'a'
          7        SEND_VAL_EX                                              'blah'
          8        DO_FCALL                                      0          
   64     9        INIT_METHOD_CALL                                         !0, 'setQueryParam'
         10        SEND_VAL_EX                                              'foo'
         11        SEND_VAL_EX                                              'bar'
         12        DO_FCALL                                      0          
   65    13        ASSIGN_OBJ                                               !0, 'scheme'
         14        OP_DATA                                                  'https'
   66    15        ASSIGN_OBJ                                               !0, 'user'
         16        OP_DATA                                                  'admin'
   67    17        ASSIGN_OBJ                                               !0, 'pass'
         18        OP_DATA                                                  'topsecret'
   69    19        CAST                                          6  ~9      !0
         20        ECHO                                                     ~9
   70    21      > RETURN                                                   1

Class Url:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eSHD8
function name:  __construct
number of ops:  38
compiled vars:  !0 = $url, !1 = $parts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'parse_url'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   15     5        INIT_FCALL                                               'array_merge'
          6        SEND_VAL                                                 <array>
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !1, $4
   16    10        FETCH_DIM_R                                      ~7      !1, 'user'
         11        ASSIGN_OBJ                                               'user'
         12        OP_DATA                                                  ~7
   17    13        FETCH_DIM_R                                      ~9      !1, 'pass'
         14        ASSIGN_OBJ                                               'pass'
         15        OP_DATA                                                  ~9
   18    16        FETCH_DIM_R                                      ~11     !1, 'scheme'
         17        ASSIGN_OBJ                                               'scheme'
         18        OP_DATA                                                  ~11
   19    19        FETCH_DIM_R                                      ~13     !1, 'host'
         20        ASSIGN_OBJ                                               'host'
         21        OP_DATA                                                  ~13
   20    22        FETCH_DIM_R                                      ~15     !1, 'port'
         23        ASSIGN_OBJ                                               'port'
         24        OP_DATA                                                  ~15
   21    25        FETCH_DIM_R                                      ~17     !1, 'path'
         26        ASSIGN_OBJ                                               'path'
         27        OP_DATA                                                  ~17
   22    28        INIT_FCALL                                               'parse_str'
         29        FETCH_DIM_R                                      ~18     !1, 'query'
         30        SEND_VAL                                                 ~18
         31        FETCH_OBJ_W                                      $19     'query'
         32        SEND_REF                                                 $19
         33        DO_ICALL                                                 
   23    34        FETCH_DIM_R                                      ~22     !1, 'fragment'
         35        ASSIGN_OBJ                                               'fragment'
         36        OP_DATA                                                  ~22
   24    37      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eSHD8
function name:  __get
number of ops:  18
compiled vars:  !0 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        INIT_FCALL                                               'property_exists'
          2        FETCH_THIS                                       ~1      
          3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        BOOL_NOT                                         ~3      $2
          7      > JMPZ                                                     ~3, ->15
   28     8    >   NEW                                              $4      'ErrorException'
          9        ROPE_INIT                                     3  ~6      'Property+'
         10        ROPE_ADD                                      1  ~6      ~6, !0
         11        ROPE_END                                      2  ~5      ~6, '+does+not+exist'
         12        SEND_VAL_EX                                              ~5
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $4
   30    15    >   FETCH_OBJ_R                                      ~9      !0
         16      > RETURN                                                   ~9
   31    17*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eSHD8
function name:  __set
number of ops:  19
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   34     2        INIT_FCALL                                               'property_exists'
          3        FETCH_THIS                                       ~2      
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > JMPZ                                                     ~4, ->16
   35     9    >   NEW                                              $5      'ErrorException'
         10        ROPE_INIT                                     3  ~7      'Property+'
         11        ROPE_ADD                                      1  ~7      ~7, !0
         12        ROPE_END                                      2  ~6      ~7, '+does+not+exist'
         13        SEND_VAL_EX                                              ~6
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $5
   37    16    >   ASSIGN_OBJ                                               !0
         17        OP_DATA                                                  !1
   38    18      > RETURN                                                   null

End of function __set

Function setqueryparam:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eSHD8
function name:  setQueryParam
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   41     2        FETCH_OBJ_W                                      $2      'query'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   42     5      > RETURN                                                   null

End of function setqueryparam

Function getqueryparam:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eSHD8
function name:  getQueryParam
number of ops:  11
compiled vars:  !0 = $key, !1 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
   44     2        FETCH_OBJ_R                                      ~2      'query'
          3        ARRAY_KEY_EXISTS                                         !0, ~2
          4      > JMPZ                                                     ~3, ->9
   45     5    >   FETCH_OBJ_R                                      ~4      'query'
          6        FETCH_DIM_R                                      ~5      ~4, 'key'
          7      > RETURN                                                   ~5
          8*       JMP                                                      ->10
   47     9    > > RETURN                                                   !1
   49    10*     > RETURN                                                   null

End of function getqueryparam

Function __tostring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 6
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 51
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
Branch analysis from position: 59
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 51
Branch analysis from position: 44
Branch analysis from position: 51
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
Branch analysis from position: 40
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
Branch analysis from position: 33
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
Branch analysis from position: 33
Branch analysis from position: 11
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
Branch analysis from position: 11
filename:       /in/eSHD8
function name:  __toString
number of ops:  65
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   FETCH_OBJ_R                                      ~0      'scheme'
          1      > JMPZ                                                     ~0, ->6
          2    >   FETCH_OBJ_R                                      ~1      'scheme'
          3        CONCAT                                           ~2      ~1, '%3A%2F%2F'
          4        QM_ASSIGN                                        ~3      ~2
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~3      ''
   53     7    >   FETCH_OBJ_R                                      ~4      'user'
          8      > JMPZ_EX                                          ~4      ~4, ->11
          9    >   FETCH_OBJ_R                                      ~5      'pass'
         10        BOOL                                             ~4      ~5
         11    > > JMPZ                                                     ~4, ->19
         12    >   FETCH_OBJ_R                                      ~6      'user'
         13        CONCAT                                           ~7      ~6, '%3A'
         14        FETCH_OBJ_R                                      ~8      'pass'
         15        CONCAT                                           ~9      ~7, ~8
         16        CONCAT                                           ~10     ~9, '%40'
         17        QM_ASSIGN                                        ~11     ~10
         18      > JMP                                                      ->27
         19    >   FETCH_OBJ_R                                      ~12     'user'
         20      > JMPZ                                                     ~12, ->25
         21    >   FETCH_OBJ_R                                      ~13     'user'
         22        CONCAT                                           ~14     ~13, '%40'
         23        QM_ASSIGN                                        ~15     ~14
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~15     ''
         26    >   QM_ASSIGN                                        ~11     ~15
         27    >   CONCAT                                           ~16     ~3, ~11
   54    28        FETCH_OBJ_R                                      ~17     'host'
         29      > JMPZ                                                     ~17, ->33
         30    >   FETCH_OBJ_R                                      ~18     'host'
         31        QM_ASSIGN                                        ~19     ~18
         32      > JMP                                                      ->34
         33    >   QM_ASSIGN                                        ~19     ''
         34    >   CONCAT                                           ~20     ~16, ~19
   55    35        FETCH_OBJ_R                                      ~21     'path'
         36      > JMPZ                                                     ~21, ->40
         37    >   FETCH_OBJ_R                                      ~22     'path'
         38        QM_ASSIGN                                        ~23     ~22
         39      > JMP                                                      ->41
         40    >   QM_ASSIGN                                        ~23     ''
         41    >   CONCAT                                           ~24     ~20, ~23
   56    42        FETCH_OBJ_R                                      ~25     'query'
         43      > JMPZ                                                     ~25, ->51
         44    >   INIT_FCALL                                               'http_build_query'
         45        FETCH_OBJ_R                                      ~26     'query'
         46        SEND_VAL                                                 ~26
         47        DO_ICALL                                         $27     
         48        CONCAT                                           ~28     '%3F', $27
         49        QM_ASSIGN                                        ~29     ~28
         50      > JMP                                                      ->52
         51    >   QM_ASSIGN                                        ~29     ''
         52    >   CONCAT                                           ~30     ~24, ~29
   57    53        FETCH_OBJ_R                                      ~31     'fragment'
         54      > JMPZ                                                     ~31, ->59
         55    >   FETCH_OBJ_R                                      ~32     'fragment'
         56        CONCAT                                           ~33     '%23', ~32
         57        QM_ASSIGN                                        ~34     ~33
         58      > JMP                                                      ->60
         59    >   QM_ASSIGN                                        ~34     ''
         60    >   CONCAT                                           ~35     ~30, ~34
         61        VERIFY_RETURN_TYPE                                       ~35
         62      > RETURN                                                   ~35
   59    63*       VERIFY_RETURN_TYPE                                       
         64*     > RETURN                                                   null

End of function __tostring

End of class Url.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.26 ms | 1416 KiB | 23 Q