3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeClass implements JsonSerializable { public function jsonSerialize() { return [get_object_vars($this)]; } } $class = new SomeClass; var_dump(json_encode($class)); var_dump(json_last_error() == JSON_ERROR_RECURSION); $arr = [$class]; var_dump(json_encode($arr)); var_dump(json_last_error() == JSON_ERROR_RECURSION);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cZlaa
function name:  (null)
number of ops:  31
compiled vars:  !0 = $class, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'someclass'
    9     1        NEW                                              $2      'SomeClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   10     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'json_encode'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                                 
   11    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'json_last_error'
         12        DO_ICALL                                         $7      
         13        IS_EQUAL                                         ~8      $7, 6
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                                 
   13    16        INIT_ARRAY                                       ~10     !0
         17        ASSIGN                                                   !1, ~10
   14    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'json_encode'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $12     
         22        SEND_VAR                                                 $12
         23        DO_ICALL                                                 
   15    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'json_last_error'
         26        DO_ICALL                                         $14     
         27        IS_EQUAL                                         ~15     $14, 6
         28        SEND_VAL                                                 ~15
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

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

End of function jsonserialize

End of class SomeClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.55 ms | 1396 KiB | 21 Q