3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements Serializable { public function jsonSerialize() { return [ 'title' => $this->title, 'parent' => $this->parent, ]; } } $f1 = new Foo(); $f1->title = 'Foo'; $f2 = new Foo(); $f2->title = 'Bar'; $f2->parent = $f1; echo json_encode($f2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WVWgi
function name:  (null)
number of ops:  18
compiled vars:  !0 = $f1, !1 = $f2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   12     1        NEW                                              $2      'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   13     4        ASSIGN_OBJ                                               !0, 'title'
          5        OP_DATA                                                  'Foo'
   15     6        NEW                                              $6      'Foo'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $6
   16     9        ASSIGN_OBJ                                               !1, 'title'
         10        OP_DATA                                                  'Bar'
   17    11        ASSIGN_OBJ                                               !1, 'parent'
         12        OP_DATA                                                  !0
   19    13        INIT_FCALL                                               'json_encode'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $11     
         16        ECHO                                                     $11
         17      > RETURN                                                   1

Class Foo:
Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WVWgi
function name:  jsonSerialize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_OBJ_R                                      ~0      'title'
          1        INIT_ARRAY                                       ~1      ~0, 'title'
    7     2        FETCH_OBJ_R                                      ~2      'parent'
          3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'parent'
          4      > RETURN                                                   ~1
    9     5*     > RETURN                                                   null

End of function jsonserialize

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.32 ms | 1395 KiB | 15 Q