3v4l.org

run code in 300+ PHP versions simultaneously
<?php class obj implements Serializable { private $data; protected $extradata; public function __construct() { $this->data = "My private data"; } public function getData() { return $this->data; } public function getExtraData(){ $this->extradata = array( 'data1','data2' ); } public function serialize() { return serialize(array( $this->data, $this->extradata, )); } public function unserialize($data) { $orgdata = unserialize($data); $this->data = $orgdata[0]; $this->extradata = $orgdata[1]; } } $obj = new obj(); $s = serialize($obj); echo 'first serialize: '; var_dump($s); echo '<br/>'; $u = unserialize($s); echo 'first unserialize: '; var_dump($u);echo '<br/>'; $u->getExtraData(); echo 'with extradata: '; var_dump($u);echo '<br/>'; $s2 = serialize($u); echo 'second serialize: '; var_dump($s2);echo '<br/>'; $u2 = unserialize($s2); echo 'second unserialize: '; var_dump($u2);echo '<br/>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pgr2a
function name:  (null)
number of ops:  48
compiled vars:  !0 = $obj, !1 = $s, !2 = $u, !3 = $s2, !4 = $u2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'obj'
   34     1        NEW                                              $5      'obj'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $5
   35     4        INIT_FCALL                                               'serialize'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
   36     8        ECHO                                                     'first+serialize%3A+'
          9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12        ECHO                                                     '%3Cbr%2F%3E'
   37    13        INIT_FCALL                                               'unserialize'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !2, $11
   38    17        ECHO                                                     'first+unserialize%3A+'
         18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21        ECHO                                                     '%3Cbr%2F%3E'
   39    22        INIT_METHOD_CALL                                         !2, 'getExtraData'
         23        DO_FCALL                                      0          
   40    24        ECHO                                                     'with+extradata%3A+'
         25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                                 
         28        ECHO                                                     '%3Cbr%2F%3E'
   41    29        INIT_FCALL                                               'serialize'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $16     
         32        ASSIGN                                                   !3, $16
   42    33        ECHO                                                     'second+serialize%3A+'
         34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                                 
         37        ECHO                                                     '%3Cbr%2F%3E'
   43    38        INIT_FCALL                                               'unserialize'
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                         $19     
         41        ASSIGN                                                   !4, $19
   44    42        ECHO                                                     'second+unserialize%3A+'
         43        INIT_FCALL                                               'var_dump'
         44        SEND_VAR                                                 !4
         45        DO_ICALL                                                 
         46        ECHO                                                     '%3Cbr%2F%3E'
         47      > RETURN                                                   1

Class obj:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pgr2a
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN_OBJ                                               'data'
          1        OP_DATA                                                  'My+private+data'
    9     2      > RETURN                                                   null

End of function __construct

Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pgr2a
function name:  getData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1      > RETURN                                                   ~0
   13     2*     > RETURN                                                   null

End of function getdata

Function getextradata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pgr2a
function name:  getExtraData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN_OBJ                                               'extradata'
   17     1        OP_DATA                                                  <array>
   19     2      > RETURN                                                   null

End of function getextradata

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pgr2a
function name:  serialize
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'serialize'
   23     1        FETCH_OBJ_R                                      ~0      'data'
          2        INIT_ARRAY                                       ~1      ~0
   24     3        FETCH_OBJ_R                                      ~2      'extradata'
          4        ADD_ARRAY_ELEMENT                                ~1      ~2
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
   26     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/pgr2a
function name:  unserialize
number of ops:  12
compiled vars:  !0 = $data, !1 = $orgdata
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   29     5        FETCH_DIM_R                                      ~5      !1, 0
          6        ASSIGN_OBJ                                               'data'
          7        OP_DATA                                                  ~5
   30     8        FETCH_DIM_R                                      ~7      !1, 1
          9        ASSIGN_OBJ                                               'extradata'
         10        OP_DATA                                                  ~7
   31    11      > RETURN                                                   null

End of function unserialize

End of class obj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.61 ms | 1396 KiB | 19 Q