3v4l.org

run code in 500+ PHP versions simultaneously
<?php # Given two classes with the same property name but different visibility class WithPublic { public $property; function __construct( $p ) { $this->property = $p; } function getProperty() { return $this->property; } } class WithPrivate { private $property; function __construct( $p ) { $this->property = $p; } function getProperty() { return $this->property; } } $priv = new WithPrivate( 'value' ); $cache = serialize( $priv ); $mut_priv_to_pub = unserialize( str_replace( '11:"WithPrivate"', '10:"WithPublic"', $cache) ); var_dump( $mut_priv_to_pub ); # class WithPublic#4 (2) { # public $property => # NULL # private $property => # string(5) "value" # } var_export( $mut_priv_to_pub->getProperty() ); # On Zend PHP: NULL # On HHVM 3.15.4, 3.17.1: 'value'
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property WithPublic::$property is deprecated in /in/jrmrO on line 18 object(WithPublic)#2 (2) { ["property"]=> NULL ["property":"WithPrivate":private]=> string(5) "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:
113.53 ms | 1497 KiB | 4 Q