3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Dummy implements JsonSerializable{ public function jsonSerialize() { global $flag; if ($flag) { exit; } else { return "xxxx"; } } } $array = array(new Dummy()); $array[] = "xxx"; register_shutdown_function(function() use($array) { global $flag; $flag = 0; var_dump(json_encode(array($array))); }); $flag = 1; var_dump(json_encode(array($array)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uSSZ6
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array, !1 = $flag
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'dummy'
   14     1        NEW                                                  $2      'Dummy'
          2        DO_FCALL                                          0          
          3        INIT_ARRAY                                           ~4      $2
          4        ASSIGN                                                       !0, ~4
   15     5        ASSIGN_DIM                                                   !0
          6        OP_DATA                                                      'xxx'
   17     7        INIT_FCALL                                                   'register_shutdown_function'
          8        DECLARE_LAMBDA_FUNCTION                              ~7      [0]
          9        BIND_LEXICAL                                                 ~7, !0
   21    10        SEND_VAL                                                     ~7
   17    11        DO_ICALL                                                     
   23    12        ASSIGN                                                       !1, 1
   24    13        INIT_FCALL                                                   'var_dump'
         14        INIT_FCALL                                                   'json_encode'
         15        INIT_ARRAY                                           ~10     !0
         16        SEND_VAL                                                     ~10
         17        DO_ICALL                                             $11     
         18        SEND_VAR                                                     $11
         19        DO_ICALL                                                     
         20      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uSSZ6
function name:  {closure:/in/uSSZ6:17}
number of ops:  11
compiled vars:  !0 = $array, !1 = $flag
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   BIND_STATIC                                                  !0
   18     1        BIND_GLOBAL                                                  !1, 'flag'
   19     2        ASSIGN                                                       !1, 0
   20     3        INIT_FCALL                                                   'var_dump'
          4        INIT_FCALL                                                   'json_encode'
          5        INIT_ARRAY                                           ~3      !0
          6        SEND_VAL                                                     ~3
          7        DO_ICALL                                             $4      
          8        SEND_VAR                                                     $4
          9        DO_ICALL                                                     
   21    10      > RETURN                                                       null

End of Dynamic Function 0

Class Dummy:
Function jsonserialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uSSZ6
function name:  jsonSerialize
number of ops:  7
compiled vars:  !0 = $flag
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   BIND_GLOBAL                                                  !0, 'flag'
    6     1      > JMPZ                                                         !0, ->5
    7     2    > > INIT_FCALL                                                   'exit'
          3*       DO_ICALL                                                     
    6     4*       JMP                                                          ->6
    9     5    > > RETURN                                                       'xxxx'
   11     6*     > RETURN                                                       null

End of function jsonserialize

End of class Dummy.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
153.07 ms | 1453 KiB | 12 Q