3v4l.org

run code in 500+ PHP versions simultaneously
<?php class obj implements Serializable { private $data; public function __construct() { $this->data = "My private data"; } public function __serialize() { echo '__serialize' . PHP_EOL; return ['foo' => $this->data]; } public function __unserialize($data) { echo '__unserialize' . PHP_EOL; $this->data = $data['foo']; } public function serialize() { echo 'serialize' . PHP_EOL; return serialize($this->data); } public function unserialize($data) { echo 'unserialize' . PHP_EOL; $this->data = unserialize($data); } public function getData() { return $this->data; } } $obj = new obj; $ser = serialize($obj); var_dump($ser); $unser = unserialize($ser); echo($unser->getData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JmIRQ
function name:  (null)
number of ops:  19
compiled vars:  !0 = $obj, !1 = $ser, !2 = $unser
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'obj'
   34     1        NEW                                                  $3      'obj'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
   35     4        INIT_FCALL                                                   'serialize'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $6      
          7        ASSIGN                                                       !1, $6
   36     8        INIT_FCALL                                                   'var_dump'
          9        SEND_VAR                                                     !1
         10        DO_ICALL                                                     
   38    11        INIT_FCALL                                                   'unserialize'
         12        SEND_VAR                                                     !1
         13        DO_ICALL                                             $9      
         14        ASSIGN                                                       !2, $9
   39    15        INIT_METHOD_CALL                                             !2, 'getData'
         16        DO_FCALL                                          0  $11     
         17        ECHO                                                         $11
         18      > RETURN                                                       1

Class obj:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JmIRQ
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                                   'data'
          1        OP_DATA                                                      'My+private+data'
    8     2      > 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/JmIRQ
function name:  __serialize
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                         '__serialize%0A'
   12     1        FETCH_OBJ_R                                          ~0      'data'
          2        INIT_ARRAY                                           ~1      ~0, 'foo'
          3      > RETURN                                                       ~1
   13     4*     > 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/JmIRQ
function name:  __unserialize
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1        ECHO                                                         '__unserialize%0A'
   16     2        FETCH_DIM_R                                          ~2      !0, 'foo'
          3        ASSIGN_OBJ                                                   'data'
          4        OP_DATA                                                      ~2
   17     5      > 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/JmIRQ
function name:  serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                         'serialize%0A'
   21     1        INIT_FCALL                                                   'serialize'
          2        FETCH_OBJ_R                                          ~0      'data'
          3        SEND_VAL                                                     ~0
          4        DO_ICALL                                             $1      
          5      > RETURN                                                       $1
   22     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/JmIRQ
function name:  unserialize
number of ops:  8
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   RECV                                                 !0      
   25     1        ECHO                                                         'unserialize%0A'
   26     2        INIT_FCALL                                                   'unserialize'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $2      
          5        ASSIGN_OBJ                                                   'data'
          6        OP_DATA                                                      $2
   27     7      > RETURN                                                       null

End of function unserialize

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

End of function getdata

End of class obj.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.15 ms | 3365 KiB | 15 Q