3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('America/New_York'); $date = new DateTime(); echo json_encode($date,JSON_FORCE_OBJECT); var_dump(json_last_error(), json_last_error_msg()); function isSerializable( $var ) { try { serialize( $var ); return TRUE; } catch( Exception $e ) { return FALSE; } } var_dump( isSerializable( DateTime() ) ); // bool(true)
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DNE3O
function name:  (null)
number of ops:  28
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'America%2FNew_York'
          2        DO_ICALL                                                 
    5     3        NEW                                              $2      'DateTime'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
    7     6        INIT_FCALL                                               'json_encode'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 16
          9        DO_ICALL                                         $5      
         10        ECHO                                                     $5
    8    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'json_last_error'
         13        DO_ICALL                                         $6      
         14        SEND_VAR                                                 $6
         15        INIT_FCALL                                               'json_last_error_msg'
         16        DO_ICALL                                         $7      
         17        SEND_VAR                                                 $7
         18        DO_ICALL                                                 
   20    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'isserializable'
         21        INIT_FCALL_BY_NAME                                       'DateTime'
         22        DO_FCALL                                      0  $9      
         23        SEND_VAR                                                 $9
         24        DO_FCALL                                      0  $10     
         25        SEND_VAR                                                 $10
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function isserializable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DNE3O
function name:  isSerializable
number of ops:  9
compiled vars:  !0 = $var, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'serialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   14     4      > RETURN                                                   <true>
          5*       JMP                                                      ->8
   15     6  E > > CATCH                                       last         'Exception'
   16     7    > > RETURN                                                   <false>
   18     8*     > RETURN                                                   null

End of function isserializable

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.59 ms | 1399 KiB | 26 Q