3v4l.org

run code in 300+ PHP versions simultaneously
<?php function prop($name = null, $unset = false) { static $data = array(); if(empty($name)) return $data; if(!empty($unset) && isset($data[$name])){ unset($data[$name]); return; } if(!isset($data[$name])){ $data[$name] = new stdClass(); } return $data[$name]; } echo "---------------------------\n"; prop('user')->name = 'Alex'; prop('user')->age = 26; prop('item')->value = 'dfg'; prop('item')->total = 2; print_r(prop()); prop('item', 'unset'); print_r(prop()); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/StK67
function name:  (null)
number of ops:  40
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                     '---------------------------%0A'
   21     1        INIT_FCALL                                               'prop'
          2        SEND_VAL                                                 'user'
          3        DO_FCALL                                      0  $0      
          4        SEPARATE                                         $0      $0
          5        ASSIGN_OBJ                                               $0, 'name'
          6        OP_DATA                                                  'Alex'
   22     7        INIT_FCALL                                               'prop'
          8        SEND_VAL                                                 'user'
          9        DO_FCALL                                      0  $2      
         10        SEPARATE                                         $2      $2
         11        ASSIGN_OBJ                                               $2, 'age'
         12        OP_DATA                                                  26
   23    13        INIT_FCALL                                               'prop'
         14        SEND_VAL                                                 'item'
         15        DO_FCALL                                      0  $4      
         16        SEPARATE                                         $4      $4
         17        ASSIGN_OBJ                                               $4, 'value'
         18        OP_DATA                                                  'dfg'
   24    19        INIT_FCALL                                               'prop'
         20        SEND_VAL                                                 'item'
         21        DO_FCALL                                      0  $6      
         22        SEPARATE                                         $6      $6
         23        ASSIGN_OBJ                                               $6, 'total'
         24        OP_DATA                                                  2
   25    25        INIT_FCALL                                               'print_r'
         26        INIT_FCALL                                               'prop'
         27        DO_FCALL                                      0  $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                                 
   27    30        INIT_FCALL                                               'prop'
         31        SEND_VAL                                                 'item'
         32        SEND_VAL                                                 'unset'
         33        DO_FCALL                                      0          
   28    34        INIT_FCALL                                               'print_r'
         35        INIT_FCALL                                               'prop'
         36        DO_FCALL                                      0  $11     
         37        SEND_VAR                                                 $11
         38        DO_ICALL                                                 
   30    39      > RETURN                                                   1

Function prop:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
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 = 14
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 11
filename:       /in/StK67
function name:  prop
number of ops:  24
compiled vars:  !0 = $name, !1 = $unset, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      <false>
    4     2        BIND_STATIC                                              !2
    6     3        ISSET_ISEMPTY_CV                                         !0
          4      > JMPZ                                                     ~3, ->6
    7     5    > > RETURN                                                   !2
    9     6    >   ISSET_ISEMPTY_CV                                 ~4      !1
          7        BOOL_NOT                                         ~5      ~4
          8      > JMPZ_EX                                          ~5      ~5, ->11
          9    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !2, !0
         10        BOOL                                             ~5      ~6
         11    > > JMPZ                                                     ~5, ->14
   10    12    >   UNSET_DIM                                                !2, !0
   11    13      > RETURN                                                   null
   14    14    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !2, !0
         15        BOOL_NOT                                         ~8      ~7
         16      > JMPZ                                                     ~8, ->21
   15    17    >   NEW                                              $10     'stdClass'
         18        DO_FCALL                                      0          
         19        ASSIGN_DIM                                               !2, !0
         20        OP_DATA                                                  $10
   17    21    >   FETCH_DIM_R                                      ~12     !2, !0
         22      > RETURN                                                   ~12
   18    23*     > RETURN                                                   null

End of function prop

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.77 ms | 1403 KiB | 22 Q