3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $priv; function setPrivA( $x ) { $this->priv = $x; } } class B extends A { private $priv; function setPrivB($foo) { $this->priv = $foo; } } class C extends A { function accessOther( $a ) { return $a->priv; } } $b = new B; $b->setPrivA('foo'); $b->setPrivB('bar'); var_dump( $b ); $c = new C; $c->priv = 'baz'; var_dump( $c ); var_dump( $c->accessOther( $b ) );
Output for git.master, git.master_jit, rfc.property-hooks
object(B)#1 (2) { ["priv":"A":private]=> string(3) "foo" ["priv":"B":private]=> string(3) "bar" } Deprecated: Creation of dynamic property C::$priv is deprecated in /in/nq2k5 on line 31 object(C)#2 (2) { ["priv":"A":private]=> NULL ["priv"]=> string(3) "baz" } Fatal error: Uncaught Error: Cannot access private property B::$priv in /in/nq2k5:21 Stack trace: #0 /in/nq2k5(33): C->accessOther(Object(B)) #1 {main} thrown in /in/nq2k5 on line 21
Process exited with code 255.

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:
59.99 ms | 406 KiB | 5 Q