3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime('yesterday'); $restrict_array = array(); if (is_callable(array($start, '__sleep'))) { echo "Called: __sleep()".PHP_EOL; var_dump($restrict_array = $start->__sleep()); echo PHP_EOL.PHP_EOL.PHP_EOL; } $serialized = array( 'class' => get_class($start), 'state' => (array) $start ); if (!empty($restrict_array)) { $serialized['state'] = array_intersect_key($serialized['state'], $restrict_array); } echo "Serialized Data:".PHP_EOL; var_dump($serialized); echo PHP_EOL.PHP_EOL.PHP_EOL; unset($start); if (is_callable(array($serialized['class'], '__set_state'))) { echo "Called: __set_state()".PHP_EOL; var_dump($serialized['class']::__set_state($serialized['state'])); echo PHP_EOL.PHP_EOL.PHP_EOL; } if (is_callable(array($serialized['class'], '__wakeup'))) { echo "Called: __wakeup()".PHP_EOL; $serialized['class']::__wakeup(); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 59
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 71
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
Branch analysis from position: 59
Branch analysis from position: 34
Branch analysis from position: 19
filename:       /in/coKi9
function name:  (null)
number of ops:  72
compiled vars:  !0 = $start, !1 = $restrict_array, !2 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   NEW                                              $3      'DateTime'
          1        SEND_VAL_EX                                              'yesterday'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
    5     4        ASSIGN                                                   !1, <array>
    6     5        INIT_FCALL                                               'is_callable'
          6        INIT_ARRAY                                       ~7      !0
          7        ADD_ARRAY_ELEMENT                                ~7      '__sleep'
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10      > JMPZ                                                     $8, ->19
    7    11    >   ECHO                                                     'Called%3A+__sleep%28%29%0A'
    8    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !0, '__sleep'
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                           ~10     !1, $9
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                                 
    9    18        ECHO                                                     '%0A%0A%0A'
   12    19    >   GET_CLASS                                        ~12     !0
         20        INIT_ARRAY                                       ~13     ~12, 'class'
   13    21        CAST                                          7  ~14     !0
         22        ADD_ARRAY_ELEMENT                                ~13     ~14, 'state'
   11    23        ASSIGN                                                   !2, ~13
   15    24        ISSET_ISEMPTY_CV                                 ~16     !1
         25        BOOL_NOT                                         ~17     ~16
         26      > JMPZ                                                     ~17, ->34
   16    27    >   INIT_FCALL                                               'array_intersect_key'
         28        FETCH_DIM_R                                      ~19     !2, 'state'
         29        SEND_VAL                                                 ~19
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $20     
         32        ASSIGN_DIM                                               !2, 'state'
         33        OP_DATA                                                  $20
   18    34    >   ECHO                                                     'Serialized+Data%3A%0A'
   19    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                                 
   20    38        ECHO                                                     '%0A%0A%0A'
   21    39        UNSET_CV                                                 !0
   22    40        INIT_FCALL                                               'is_callable'
         41        FETCH_DIM_R                                      ~22     !2, 'class'
         42        INIT_ARRAY                                       ~23     ~22
         43        ADD_ARRAY_ELEMENT                                ~23     '__set_state'
         44        SEND_VAL                                                 ~23
         45        DO_ICALL                                         $24     
         46      > JMPZ                                                     $24, ->59
   23    47    >   ECHO                                                     'Called%3A+__set_state%28%29%0A'
   24    48        INIT_FCALL                                               'var_dump'
         49        FETCH_DIM_R                                      ~25     !2, 'class'
         50        FETCH_CLASS                                   0  $26     ~25
         51        INIT_STATIC_METHOD_CALL                                  $26, '__set_state'
         52        CHECK_FUNC_ARG                                           
         53        FETCH_DIM_FUNC_ARG                               $27     !2, 'state'
         54        SEND_FUNC_ARG                                            $27
         55        DO_FCALL                                      0  $28     
         56        SEND_VAR                                                 $28
         57        DO_ICALL                                                 
   25    58        ECHO                                                     '%0A%0A%0A'
   27    59    >   INIT_FCALL                                               'is_callable'
         60        FETCH_DIM_R                                      ~30     !2, 'class'
         61        INIT_ARRAY                                       ~31     ~30
         62        ADD_ARRAY_ELEMENT                                ~31     '__wakeup'
         63        SEND_VAL                                                 ~31
         64        DO_ICALL                                         $32     
         65      > JMPZ                                                     $32, ->71
   28    66    >   ECHO                                                     'Called%3A+__wakeup%28%29%0A'
   29    67        FETCH_DIM_R                                      ~33     !2, 'class'
         68        FETCH_CLASS                                   0  $34     ~33
         69        INIT_STATIC_METHOD_CALL                                  $34, '__wakeup'
         70        DO_FCALL                                      0          
   30    71    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.83 ms | 1400 KiB | 19 Q