3v4l.org

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

Class Fruit:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nk4Ek
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $1      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'lastEaten'
          3        OP_DATA                                                  $1
   11     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/nk4Ek
function name:  jsonSerialize
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'type'
          1        INIT_ARRAY                                       ~1      ~0, 'type'
   16     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
   18     8*     > RETURN                                                   null

End of function jsonserialize

End of class Fruit.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.56 ms | 1396 KiB | 17 Q