3v4l.org

run code in 500+ 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:  51
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        FRAMELESS_ICALL_3                str_replace         ~16     '10%3A%22WithPublic%22', '11%3A%22WithPrivate%22'
         19        OP_DATA                                                      !1
         20        SEND_VAL                                                     ~16
   19    21        DO_ICALL                                             $17     
         22        ASSIGN                                                       !4, $17
   21    23        INIT_FCALL                                                   'var_dump'
         24        SEND_VAR                                                     !4
         25        DO_ICALL                                                     
   23    26        ECHO                                                         'Property+should+be+%27value%27%3A+'
   24    27        INIT_FCALL                                                   'var_export'
         28        INIT_METHOD_CALL                                             !4, 'getProperty'
         29        DO_FCALL                                          0  $20     
         30        SEND_VAR                                                     $20
         31        DO_ICALL                                                     
         32        ECHO                                                         '%0A'
   26    33        ECHO                                                         '%0AClass+with+private+property+unserialized+to+class+with+public+property%0A'
   27    34        INIT_FCALL                                                   'unserialize'
   28    35        FRAMELESS_ICALL_3                str_replace         ~22     '11%3A%22WithPrivate%22', '10%3A%22WithPublic%22'
         36        OP_DATA                                                      !3
         37        SEND_VAL                                                     ~22
   27    38        DO_ICALL                                             $23     
         39        ASSIGN                                                       !5, $23
   29    40        INIT_FCALL                                                   'var_dump'
         41        SEND_VAR                                                     !5
         42        DO_ICALL                                                     
   31    43        ECHO                                                         'Property+should+be+%27value%27%3A+'
   32    44        INIT_FCALL                                                   'var_export'
         45        INIT_METHOD_CALL                                             !5, 'getProperty'
         46        DO_FCALL                                          0  $26     
         47        SEND_VAR                                                     $26
         48        DO_ICALL                                                     
         49        ECHO                                                         '%0A'
         50      > 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.5.0


preferences:
164.17 ms | 2711 KiB | 17 Q