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";
Output for git.master, git.master_jit, rfc.property-hooks
Class with public property unserialized to class with private property object(WithPrivate)#3 (1) { ["property":"WithPrivate":private]=> string(5) "value" } Property should be 'value': valueNULL Class with private property unserialized to class with public property Deprecated: Creation of dynamic property WithPublic::$property is deprecated in /in/QKTGW on line 27 object(WithPublic)#4 (2) { ["property"]=> NULL ["property":"WithPrivate":private]=> string(5) "value" } Property should be 'value': NULL

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.66 ms | 407 KiB | 5 Q