3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SerialDateTime extends DateTime implements JsonSerializable{ public function jsonSerialize(){ return $this->getTimestamp(); } } class StringDateTime extends DateTime{ public function __toString(){ return ''.$this->getTimestamp(); } } $j = new SerialDateTime; $s = new StringDateTime; //echo $j."\n"; echo $s."\n"; echo json_encode(array($j, $s));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FaXks
function name:  (null)
number of ops:  17
compiled vars:  !0 = $j, !1 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'serialdatetime', 'datetime'
   10     1        DECLARE_CLASS                                            'stringdatetime', 'datetime'
   17     2        NEW                                              $2      'SerialDateTime'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   18     5        NEW                                              $5      'StringDateTime'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   21     8        CONCAT                                           ~8      !1, '%0A'
          9        ECHO                                                     ~8
   22    10        INIT_FCALL                                               'json_encode'
         11        INIT_ARRAY                                       ~9      !0
         12        ADD_ARRAY_ELEMENT                                ~9      !1
         13        SEND_VAL                                                 ~9
         14        DO_ICALL                                         $10     
         15        ECHO                                                     $10
         16      > RETURN                                                   1

Class SerialDateTime:
Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FaXks
function name:  jsonSerialize
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_METHOD_CALL                                         'getTimestamp'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
    7     3*     > RETURN                                                   null

End of function jsonserialize

End of class SerialDateTime.

Class StringDateTime:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FaXks
function name:  __toString
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_METHOD_CALL                                         'getTimestamp'
          1        DO_FCALL                                      0  $0      
          2        CONCAT                                           ~1      '', $0
          3        VERIFY_RETURN_TYPE                                       ~1
          4      > RETURN                                                   ~1
   14     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function __tostring

End of class StringDateTime.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.65 ms | 1396 KiB | 15 Q