3v4l.org

run code in 500+ PHP versions simultaneously
<?php $obj = new stdClass(); $obj->name = 'Fred'; $obj->job = new stdClass(); $obj->job->position = 'Janitor'; $obj->job->years = 4; print_r($obj); echo 'Years in current job: '.string($obj, 'job->years').PHP_EOL; function string($obj, $path_str) { $val = null; $path = preg_split('/->/', $path_str); $node = $obj; while (($prop = array_shift($path)) !== null) { if (!is_object($obj) || !property_exists($node, $prop)) { $val = null; break; } $val = $node->$prop; // TODO: Insert any logic here for cleaning up $val $node = $node->$prop; } return $val; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9L4gc
function name:  (null)
number of ops:  26
compiled vars:  !0 = $obj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   NEW                                                  $1      'stdClass'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
    3     3        ASSIGN_OBJ                                                   !0, 'name'
          4        OP_DATA                                                      'Fred'
    4     5        NEW                                                  $6      'stdClass'
          6        DO_FCALL                                          0          
          7        ASSIGN_OBJ                                                   !0, 'job'
          8        OP_DATA                                                      $6
    5     9        FETCH_OBJ_W                                          $8      !0, 'job'
         10        ASSIGN_OBJ                                                   $8, 'position'
         11        OP_DATA                                                      'Janitor'
    6    12        FETCH_OBJ_W                                          $10     !0, 'job'
         13        ASSIGN_OBJ                                                   $10, 'years'
         14        OP_DATA                                                      4
    7    15        INIT_FCALL                                                   'print_r'
         16        SEND_VAR                                                     !0
         17        DO_ICALL                                                     
   10    18        INIT_FCALL_BY_NAME                                           'string'
         19        SEND_VAR_EX                                                  !0
         20        SEND_VAL_EX                                                  'job-%3Eyears'
         21        DO_FCALL                                          0  $13     
         22        CONCAT                                               ~14     'Years+in+current+job%3A+', $13
         23        CONCAT                                               ~15     ~14, '%0A'
         24        ECHO                                                         ~15
   31    25      > RETURN                                                       1

Function string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
Branch analysis from position: 10
Branch analysis from position: 16
filename:       /in/9L4gc
function name:  string
number of ops:  31
compiled vars:  !0 = $obj, !1 = $path_str, !2 = $val, !3 = $path, !4 = $node, !5 = $prop
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   14     2        ASSIGN                                                       !2, null
   16     3        INIT_FCALL                                                   'preg_split'
          4        SEND_VAL                                                     '%2F-%3E%2F'
          5        SEND_VAR                                                     !1
          6        DO_ICALL                                             $7      
          7        ASSIGN                                                       !3, $7
   17     8        ASSIGN                                                       !4, !0
   18     9      > JMP                                                          ->23
   19    10    >   TYPE_CHECK                                      256  ~10     !0
         11        BOOL_NOT                                             ~11     ~10
         12      > JMPNZ_EX                                             ~11     ~11, ->16
         13    >   FRAMELESS_ICALL_2                property_exists      ~12     !4, !5
         14        BOOL_NOT                                             ~13     ~12
         15        BOOL                                                 ~11     ~13
         16    > > JMPZ                                                         ~11, ->19
   20    17    >   ASSIGN                                                       !2, null
   21    18      > JMP                                                          ->29
   24    19    >   FETCH_OBJ_R                                          ~15     !4, !5
         20        ASSIGN                                                       !2, ~15
   27    21        FETCH_OBJ_R                                          ~17     !4, !5
         22        ASSIGN                                                       !4, ~17
   18    23    >   INIT_FCALL                                                   'array_shift'
         24        SEND_REF                                                     !3
         25        DO_ICALL                                             $19     
         26        ASSIGN                                               ~20     !5, $19
         27        TYPE_CHECK                                      1020          ~20
         28      > JMPNZ                                                        ~21, ->10
   30    29    > > RETURN                                                       !2
   31    30*     > RETURN                                                       null

End of function string

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.57 ms | 3374 KiB | 16 Q