3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements Serializable { private $foo = "Test"; public function __serialize(): array { return [ 'foo' => $this->foo ]; } public function __unserialize( array $data ): void { $this->foo = $data['foo']; } public function serialize() { return serialize( $this->__serialize() ); } public function unserialize( $serialized ): void { $this->__unserialize( unserialize( $serialized ) ); } } echo serialize(new Test()) . "\n"; // PHP 7.00 - 7.3.33 echo get_class(unserialize('C:4:"Test":27:{a:1:{s:3:"foo";s:4:"Test";}}')) . "\n"; // PHP 7.4.0 - 8.1.9 echo get_class(unserialize('O:4:"Test":1:{s:3:"foo";s:4:"Test";}')) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GmmmL
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'test'
   26     1        INIT_FCALL                                               'serialize'
          2        NEW                                              $0      'Test'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $2      
          6        CONCAT                                           ~3      $2, '%0A'
          7        ECHO                                                     ~3
   29     8        INIT_FCALL                                               'unserialize'
          9        SEND_VAL                                                 'C%3A4%3A%22Test%22%3A27%3A%7Ba%3A1%3A%7Bs%3A3%3A%22foo%22%3Bs%3A4%3A%22Test%22%3B%7D%7D'
         10        DO_ICALL                                         $4      
         11        GET_CLASS                                        ~5      $4
         12        CONCAT                                           ~6      ~5, '%0A'
         13        ECHO                                                     ~6
   32    14        INIT_FCALL                                               'unserialize'
         15        SEND_VAL                                                 'O%3A4%3A%22Test%22%3A1%3A%7Bs%3A3%3A%22foo%22%3Bs%3A4%3A%22Test%22%3B%7D'
         16        DO_ICALL                                         $7      
         17        GET_CLASS                                        ~8      $7
         18        CONCAT                                           ~9      ~8, '%0A'
         19        ECHO                                                     ~9
         20      > RETURN                                                   1

Class Test:
Function __serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GmmmL
function name:  __serialize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~0      'foo'
          1        INIT_ARRAY                                       ~1      ~0, 'foo'
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   10     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __serialize

Function __unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GmmmL
function name:  __unserialize
number of ops:  5
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        FETCH_DIM_R                                      ~2      !0, 'foo'
          2        ASSIGN_OBJ                                               'foo'
          3        OP_DATA                                                  ~2
   14     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/GmmmL
function name:  serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'serialize'
          1        INIT_METHOD_CALL                                         '__serialize'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   18     6*     > RETURN                                                   null

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GmmmL
function name:  unserialize
number of ops:  8
compiled vars:  !0 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_METHOD_CALL                                         '__unserialize'
          2        INIT_FCALL                                               'unserialize'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR_NO_REF_EX                                       $1
          6        DO_FCALL                                      0          
   22     7      > RETURN                                                   null

End of function unserialize

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
207.41 ms | 1400 KiB | 17 Q