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; 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" } Fatal error: Uncaught Error: Cannot access private property B::$priv in /in/5iT1L:21 Stack trace: #0 /in/5iT1L(31): C->accessOther(Object(B)) #1 {main} thrown in /in/5iT1L 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:
36.14 ms | 401 KiB | 8 Q