3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('session.serialize_handler', 'php_serialize'); class SerializableClass implements Serializable { public $sharedProp; public function __construct($prop) { $this->sharedProp = $prop; } public function __set($key, $value) { $this->$key = $value; } public function serialize() { return serialize(get_object_vars($this)); } public function unserialize($data) { $ar = unserialize($data); if ($ar === false) { return; } foreach ($ar as $k => $v) { $this->__set($k, $v); } } } // Shared object that acts as property of two another objects stored in session $testPropertyObj = new stdClass(); $testPropertyObj->name = 'test'; // Two instances of \SerializableClass that shares property $sessionObject = [ 'obj1' => new SerializableClass($testPropertyObj), 'obj2' => new SerializableClass($testPropertyObj), ]; session_start(); $_SESSION = $sessionObject; $sessionString = session_encode(); session_decode($sessionString); echo serialize($sessionObject) . "\n"; echo $sessionString . "\n"; echo "\n\n"; var_dump($_SESSION);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HeLT4
function name:  (null)
number of ops:  42
compiled vars:  !0 = $testPropertyObj, !1 = $sessionObject, !2 = $sessionString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'session.serialize_handler'
          2        SEND_VAL                                                 'php_serialize'
          3        DO_ICALL                                                 
    5     4        DECLARE_CLASS                                            'serializableclass'
   32     5        NEW                                              $4      'stdClass'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $4
   33     8        ASSIGN_OBJ                                               !0, 'name'
          9        OP_DATA                                                  'test'
   37    10        NEW                                              $8      'SerializableClass'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
         13        INIT_ARRAY                                       ~10     $8, 'obj1'
   38    14        NEW                                              $11     'SerializableClass'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0          
         17        ADD_ARRAY_ELEMENT                                ~10     $11, 'obj2'
   36    18        ASSIGN                                                   !1, ~10
   40    19        INIT_FCALL                                               'session_start'
         20        DO_ICALL                                                 
   41    21        FETCH_W                      global              $15     '_SESSION'
         22        ASSIGN                                                   $15, !1
   43    23        INIT_FCALL                                               'session_encode'
         24        DO_ICALL                                         $17     
         25        ASSIGN                                                   !2, $17
   44    26        INIT_FCALL                                               'session_decode'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                                 
   46    29        INIT_FCALL                                               'serialize'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $20     
         32        CONCAT                                           ~21     $20, '%0A'
         33        ECHO                                                     ~21
   47    34        CONCAT                                           ~22     !2, '%0A'
         35        ECHO                                                     ~22
   48    36        ECHO                                                     '%0A%0A'
   49    37        INIT_FCALL                                               'var_dump'
         38        FETCH_R                      global              ~23     '_SESSION'
         39        SEND_VAL                                                 ~23
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Class SerializableClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HeLT4
function name:  __construct
number of ops:  4
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'sharedProp'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HeLT4
function name:  __set
number of ops:  5
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   14     4      > RETURN                                                   null

End of function __set

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

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/HeLT4
function name:  unserialize
number of ops:  18
compiled vars:  !0 = $data, !1 = $ar, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   22     5        TYPE_CHECK                                    4          !1
          6      > JMPZ                                                     ~6, ->8
   23     7    > > RETURN                                                   null
   25     8    > > FE_RESET_R                                       $7      !1, ->16
          9    > > FE_FETCH_R                                       ~8      $7, !2, ->16
         10    >   ASSIGN                                                   !3, ~8
   26    11        INIT_METHOD_CALL                                         '__set'
         12        SEND_VAR_EX                                              !3
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
   25    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $7
   28    17      > RETURN                                                   null

End of function unserialize

End of class SerializableClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.56 ms | 1404 KiB | 29 Q