3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = json_encode(['end' => json_decode(null, true)]); class A implements \JsonSerializable { function jsonSerialize() { return ['end' => json_decode(null, true)]; } } $a = new A(); $res = json_encode($a); var_dump($result); var_dump($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIePG
function name:  (null)
number of ops:  24
compiled vars:  !0 = $result, !1 = $a, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_encode'
          1        INIT_FCALL                                               'json_decode'
          2        SEND_VAL                                                 null
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        INIT_ARRAY                                       ~4      $3, 'end'
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !0, $5
    4     9        DECLARE_CLASS                                            'a'
   11    10        NEW                                              $7      'A'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $7
   12    13        INIT_FCALL                                               'json_encode'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !2, $10
   14    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
   15    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Class A:
Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIePG
function name:  jsonSerialize
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 null
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $0      
          4        INIT_ARRAY                                       ~1      $0, 'end'
          5      > RETURN                                                   ~1
    9     6*     > RETURN                                                   null

End of function jsonserialize

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.48 ms | 1396 KiB | 19 Q