3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Test implements Serializable { public $member, $message; function __construct($message) { $this->message = $message; } function serialize() { return serialize(array($this->message, $this->member)); } function unserialize($serialized) { list($this->message, $this->member) = unserialize($serialized); } } $constructed = new Test("original"); $constructed->member = $constructed; //References to self (in this example pointless, but technically legal) var_dump($constructed); $transported = unserialize(serialize($constructed)); // Segmentation fault.
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t2m1F
function name:  (null)
number of ops:  18
compiled vars:  !0 = $constructed, !1 = $transported
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                                'test'
   18     1        NEW                                                  $2      'Test'
          2        SEND_VAL_EX                                                  'original'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   19     5        ASSIGN_OBJ                                                   !0, 'member'
          6        OP_DATA                                                      !0
   20     7        INIT_FCALL                                                   'var_dump'
          8        SEND_VAR                                                     !0
          9        DO_ICALL                                                     
   21    10        INIT_FCALL                                                   'unserialize'
         11        INIT_FCALL                                                   'serialize'
         12        SEND_VAR                                                     !0
         13        DO_ICALL                                             $7      
         14        SEND_VAR                                                     $7
         15        DO_ICALL                                             $8      
         16        ASSIGN                                                       !1, $8
         17      > RETURN                                                       1

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

End of function __construct

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t2m1F
function name:  serialize
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                                   'serialize'
          1        FETCH_OBJ_R                                          ~0      'message'
          2        INIT_ARRAY                                           ~1      ~0
          3        FETCH_OBJ_R                                          ~2      'member'
          4        ADD_ARRAY_ELEMENT                                    ~1      ~2
          5        SEND_VAL                                                     ~1
          6        DO_ICALL                                             $3      
          7      > RETURN                                                       $3
   11     8*     > 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/t2m1F
function name:  unserialize
number of ops:  12
compiled vars:  !0 = $serialized
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   14     1        INIT_FCALL                                                   'unserialize'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $1      
          4        FETCH_LIST_R                                         $2      $1, 0
          5        ASSIGN_OBJ                                                   'message'
          6        OP_DATA                                                      $2
          7        FETCH_LIST_R                                         $4      $1, 1
          8        ASSIGN_OBJ                                                   'member'
          9        OP_DATA                                                      $4
         10        FREE                                                         $1
   15    11      > RETURN                                                       null

End of function unserialize

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.13 ms | 3348 KiB | 16 Q