3v4l.org

run code in 300+ PHP versions simultaneously
<?php class JSON { function parse($json) { return new JSONObject(json_parse($json, true)); } } class JSONObject { function JSONObject($obj) { $this->obj = $obj; } function __get($val) { return new JSONObject($this->obj[$val]); } } $json = new JSON(); $obj = $json->parse('{"a":{"c":1},"b":2}'); var_dump($obj, $obj['a'], $obj['b'], $obj['a']['c']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Y6sQ
function name:  (null)
number of ops:  18
compiled vars:  !0 = $json, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $2      'JSON'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   23     3        INIT_METHOD_CALL                                         !0, 'parse'
          4        SEND_VAL_EX                                              '%7B%22a%22%3A%7B%22c%22%3A1%7D%2C%22b%22%3A2%7D'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   24     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        FETCH_DIM_R                                      ~7      !1, 'a'
         10        SEND_VAL                                                 ~7
         11        FETCH_DIM_R                                      ~8      !1, 'b'
         12        SEND_VAL                                                 ~8
         13        FETCH_DIM_R                                      ~9      !1, 'a'
         14        FETCH_DIM_R                                      ~10     ~9, 'c'
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class JSON:
Function parse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Y6sQ
function name:  parse
number of ops:  10
compiled vars:  !0 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        NEW                                              $1      'JSONObject'
          2        INIT_FCALL_BY_NAME                                       'json_parse'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAL_EX                                              <true>
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR_NO_REF_EX                                       $2
          7        DO_FCALL                                      0          
          8      > RETURN                                                   $1
    6     9*     > RETURN                                                   null

End of function parse

End of class JSON.

Class JSONObject:
Function jsonobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Y6sQ
function name:  JSONObject
number of ops:  4
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ASSIGN_OBJ                                               'obj'
          2        OP_DATA                                                  !0
   14     3      > RETURN                                                   null

End of function jsonobject

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Y6sQ
function name:  __get
number of ops:  9
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        NEW                                              $1      'JSONObject'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $2      'obj'
          4        FETCH_DIM_FUNC_ARG                               $3      $2, !0
          5        SEND_FUNC_ARG                                            $3
          6        DO_FCALL                                      0          
          7      > RETURN                                                   $1
   18     8*     > RETURN                                                   null

End of function __get

End of class JSONObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.96 ms | 1400 KiB | 15 Q