3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('America/Los_Angeles'); class Fruit { public $type = 'Apple', $lastEaten = null; public function __construct() { $this->lastEaten = new DateTime(); } public function jsonSerialize() { return array( 'type' => $this->type, 'lastEaten' => $this->lastEaten->format(DateTime::ISO8601) ); } } echo $s = json_encode(new Fruit()); var_dump(json_decode($s));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Krt84
function name:  (null)
number of ops:  17
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'America%2FLos_Angeles'
          2        DO_ICALL                                                 
   22     3        INIT_FCALL                                               'json_encode'
          4        NEW                                              $2      'Fruit'
          5        DO_FCALL                                      0          
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                         $4      
          8        ASSIGN                                           ~5      !0, $4
          9        ECHO                                                     ~5
   23    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'json_decode'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Class Fruit:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Krt84
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $1      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'lastEaten'
          3        OP_DATA                                                  $1
   12     4      > 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/Krt84
function name:  jsonSerialize
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'type'
          1        INIT_ARRAY                                       ~1      ~0, 'type'
   17     2        FETCH_OBJ_R                                      ~2      'lastEaten'
          3        INIT_METHOD_CALL                                         ~2, 'format'
          4        SEND_VAL_EX                                              'Y-m-d%5CTH%3Ai%3AsO'
          5        DO_FCALL                                      0  $3      
          6        ADD_ARRAY_ELEMENT                                ~1      $3, 'lastEaten'
          7      > RETURN                                                   ~1
   19     8*     > RETURN                                                   null

End of function jsonserialize

End of class Fruit.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.31 ms | 1396 KiB | 21 Q