3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo implements JsonSerializable { private $thing; public function __construct($thing) { $this->thing = $thing; } public function jsonSerialize() { return [ 'thing' => $this->thing, ]; } } $foo = new Foo('Foo Bar'); echo json_encode(['the_foo' => $foo]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c9UeF
function name:  (null)
number of ops:  11
compiled vars:  !0 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'foo'
   20     1        NEW                                                  $1      'Foo'
          2        SEND_VAL_EX                                                  'Foo+Bar'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $1
   22     5        INIT_FCALL                                                   'json_encode'
          6        INIT_ARRAY                                           ~4      !0, 'the_foo'
          7        SEND_VAL                                                     ~4
          8        DO_ICALL                                             $5      
          9        ECHO                                                         $5
         10      > RETURN                                                       1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c9UeF
function name:  __construct
number of ops:  4
compiled vars:  !0 = $thing
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    9     1        ASSIGN_OBJ                                                   'thing'
          2        OP_DATA                                                      !0
   10     3      > RETURN                                                       null

End of function __construct

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

End of function jsonserialize

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
214.23 ms | 2127 KiB | 14 Q