3v4l.org

run code in 300+ PHP versions simultaneously
<?php # base class class Test_TestClassBase { public $x = 4; public function __wakeup() { var_dump("__wakeup"); } public function __sleep() { var_dump("__sleep"); return array_keys(get_object_vars($this)); } public function unserialize($input) { var_dump("unserialize"); } public function serialize() { var_dump("serialize"); return serialize(get_object_vars($this)); } } # derived classes class Test_TestClassA extends Test_TestClassBase {} class Test_TestClassB extends Test_TestClassBase implements Serializable {} class Test_TestClassAA extends Test_TestClassA implements Serializable {} class Test_TestClassBB extends Test_TestClassB {} # run our serialisation foreach(array("Test_TestClassA", "Test_TestClassB", "Test_TestClassAA", "Test_TestClassBB") as $class) { $serialised = 'O:'.strlen($class).':"'.$class.'":1:{s:1:"x";i:4;}'; var_dump("(input) ".$serialised); var_dump("(output) ".(unserialize($serialised) instanceof $class ? "true (passing)" : "false (failing)")); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/XRr5t
function name:  (null)
number of ops:  31
compiled vars:  !0 = $class, !1 = $serialised
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   DECLARE_CLASS                                            'test_testclassb', 'test_testclassbase'
   38     1        DECLARE_CLASS                                            'test_testclassaa', 'test_testclassa'
   39     2        DECLARE_CLASS                                            'test_testclassbb', 'test_testclassb'
   43     3      > FE_RESET_R                                       $2      <array>, ->29
          4    > > FE_FETCH_R                                               $2, !0, ->29
   45     5    >   STRLEN                                           ~3      !0
          6        CONCAT                                           ~4      'O%3A', ~3
          7        CONCAT                                           ~5      ~4, '%3A%22'
          8        CONCAT                                           ~6      ~5, !0
          9        CONCAT                                           ~7      ~6, '%22%3A1%3A%7Bs%3A1%3A%22x%22%3Bi%3A4%3B%7D'
         10        ASSIGN                                                   !1, ~7
   47    11        INIT_FCALL                                               'var_dump'
         12        CONCAT                                           ~9      '%28input%29++', !1
         13        SEND_VAL                                                 ~9
         14        DO_ICALL                                                 
   48    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'unserialize'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $11     
         19        FETCH_CLASS                                   0  $12     !0
         20        INSTANCEOF                                               $11, $12
         21      > JMPZ                                                     ~13, ->24
         22    >   QM_ASSIGN                                        ~14     'true+%28passing%29'
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~14     'false+%28failing%29'
         25    >   CONCAT                                           ~15     '%28output%29+', ~14
         26        SEND_VAL                                                 ~15
         27        DO_ICALL                                                 
   43    28      > JMP                                                      ->4
         29    >   FE_FREE                                                  $2
   49    30      > RETURN                                                   1

Class Test_TestClassBase:
Function __wakeup:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  __wakeup
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '__wakeup'
          2        DO_ICALL                                                 
   12     3      > RETURN                                                   null

End of function __wakeup

Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  __sleep
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '__sleep'
          2        DO_ICALL                                                 
   18     3        INIT_FCALL                                               'array_keys'
          4        INIT_FCALL                                               'get_object_vars'
          5        FETCH_THIS                                       ~1      
          6        SEND_VAL                                                 ~1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
   19    11*     > RETURN                                                   null

End of function __sleep

Function unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  unserialize
number of ops:  5
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'unserialize'
          3        DO_ICALL                                                 
   24     4      > RETURN                                                   null

End of function unserialize

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  serialize
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'serialize'
          2        DO_ICALL                                                 
   30     3        INIT_FCALL                                               'serialize'
          4        INIT_FCALL                                               'get_object_vars'
          5        FETCH_THIS                                       ~1      
          6        SEND_VAL                                                 ~1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
   31    11*     > RETURN                                                   null

End of function serialize

End of class Test_TestClassBase.

Class Test_TestClassA:
Function __wakeup:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  __wakeup
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '__wakeup'
          2        DO_ICALL                                                 
   12     3      > RETURN                                                   null

End of function __wakeup

Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  __sleep
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '__sleep'
          2        DO_ICALL                                                 
   18     3        INIT_FCALL                                               'array_keys'
          4        INIT_FCALL                                               'get_object_vars'
          5        FETCH_THIS                                       ~1      
          6        SEND_VAL                                                 ~1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
   19    11*     > RETURN                                                   null

End of function __sleep

Function unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  unserialize
number of ops:  5
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'unserialize'
          3        DO_ICALL                                                 
   24     4      > RETURN                                                   null

End of function unserialize

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRr5t
function name:  serialize
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'serialize'
          2        DO_ICALL                                                 
   30     3        INIT_FCALL                                               'serialize'
          4        INIT_FCALL                                               'get_object_vars'
          5        FETCH_THIS                                       ~1      
          6        SEND_VAL                                                 ~1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
   31    11*     > RETURN                                                   null

End of function serialize

End of class Test_TestClassA.

Class Test_TestClassB: [no user functions]
Class Test_TestClassAA: [no user functions]
Class Test_TestClassBB: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.61 ms | 1408 KiB | 23 Q