3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WithPublic { public $property; function __construct( $p ) { $this->property = $p; } function getProperty() { print $this->property; } } class WithPrivate { private $property; function __construct( $p ) { $this->property = $p; } function getProperty() { print $this->property; } } $pub = new WithPublic( 'value' ); $pub_s = serialize( $pub ); $priv = new WithPrivate( 'value' ); $priv_s = serialize( $priv ); echo "Class with public property unserialized to class with private property\n"; $mut_pub_to_priv = unserialize( str_replace( '10:"WithPublic"', '11:"WithPrivate"', $pub_s ) ); var_dump( $mut_pub_to_priv ); echo "Property should be 'value': "; var_export( $mut_pub_to_priv->getProperty() ); echo "\n"; echo "\nClass with private property unserialized to class with public property\n"; $mut_priv_to_pub = unserialize( str_replace( '11:"WithPrivate"', '10:"WithPublic"', $priv_s ) ); var_dump( $mut_priv_to_pub ); echo "Property should be 'value': "; var_export( $mut_priv_to_pub->getProperty() ); echo "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QKTGW
function name:  (null)
number of ops:  57
compiled vars:  !0 = $pub, !1 = $pub_s, !2 = $priv, !3 = $priv_s, !4 = $mut_pub_to_priv, !5 = $mut_priv_to_pub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $6      'WithPublic'
          1        SEND_VAL_EX                                              'value'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
   13     4        INIT_FCALL                                               'serialize'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $9      
          7        ASSIGN                                                   !1, $9
   15     8        NEW                                              $11     'WithPrivate'
          9        SEND_VAL_EX                                              'value'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $11
   16    12        INIT_FCALL                                               'serialize'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !3, $14
   18    16        ECHO                                                     'Class+with+public+property+unserialized+to+class+with+private+property%0A'
   19    17        INIT_FCALL                                               'unserialize'
   20    18        INIT_FCALL                                               'str_replace'
         19        SEND_VAL                                                 '10%3A%22WithPublic%22'
         20        SEND_VAL                                                 '11%3A%22WithPrivate%22'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $16     
         23        SEND_VAR                                                 $16
   19    24        DO_ICALL                                         $17     
         25        ASSIGN                                                   !4, $17
   21    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                                 
   23    29        ECHO                                                     'Property+should+be+%27value%27%3A+'
   24    30        INIT_FCALL                                               'var_export'
         31        INIT_METHOD_CALL                                         !4, 'getProperty'
         32        DO_FCALL                                      0  $20     
         33        SEND_VAR                                                 $20
         34        DO_ICALL                                                 
         35        ECHO                                                     '%0A'
   26    36        ECHO                                                     '%0AClass+with+private+property+unserialized+to+class+with+public+property%0A'
   27    37        INIT_FCALL                                               'unserialize'
   28    38        INIT_FCALL                                               'str_replace'
         39        SEND_VAL                                                 '11%3A%22WithPrivate%22'
         40        SEND_VAL                                                 '10%3A%22WithPublic%22'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                         $22     
         43        SEND_VAR                                                 $22
   27    44        DO_ICALL                                         $23     
         45        ASSIGN                                                   !5, $23
   29    46        INIT_FCALL                                               'var_dump'
         47        SEND_VAR                                                 !5
         48        DO_ICALL                                                 
   31    49        ECHO                                                     'Property+should+be+%27value%27%3A+'
   32    50        INIT_FCALL                                               'var_export'
         51        INIT_METHOD_CALL                                         !5, 'getProperty'
         52        DO_FCALL                                      0  $26     
         53        SEND_VAR                                                 $26
         54        DO_ICALL                                                 
         55        ECHO                                                     '%0A'
         56      > RETURN                                                   1

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

End of function __construct

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

End of function getproperty

End of class WithPublic.

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

End of function __construct

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

End of function getproperty

End of class WithPrivate.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.61 ms | 1466 KiB | 18 Q