3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements \JsonSerializable { protected $a; protected $b; public $c; public function __construct() { $this->a = 1; $this->b = 2; $this->c = 3; } public function jsonSerialize() { return [$this->a, $this->b]; } } $t = new Test(); echo $t->jsonSerialize(); echo json_encode($t);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qikR4
function name:  (null)
number of ops:  12
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'test'
   19     1        NEW                                              $1      'Test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   21     4        INIT_METHOD_CALL                                         !0, 'jsonSerialize'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   22     7        INIT_FCALL                                               'json_encode'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        ECHO                                                     $5
         11      > RETURN                                                   1

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qikR4
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN_OBJ                                               'a'
          1        OP_DATA                                                  1
   10     2        ASSIGN_OBJ                                               'b'
          3        OP_DATA                                                  2
   11     4        ASSIGN_OBJ                                               'c'
          5        OP_DATA                                                  3
   12     6      > 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/qikR4
function name:  jsonSerialize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        INIT_ARRAY                                       ~1      ~0
          2        FETCH_OBJ_R                                      ~2      'b'
          3        ADD_ARRAY_ELEMENT                                ~1      ~2
          4      > RETURN                                                   ~1
   16     5*     > RETURN                                                   null

End of function jsonserialize

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.32 ms | 1396 KiB | 15 Q