3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { } class B extends A { public parent $instOfParent; # equivalent to "public A $instOfParent" } class C extends B { } class Beta extends A { } $b = new B(); $b->instOfParent = new A(); # A is B's parent var_dump($b); $b->instOfParent = new A(); # B is a sub-class of A var_dump($b); $b->instOfParent = new C(); # C is a sub-sub-class of A var_dump($b); $b->instOfParent = new Beta(); # Beta is a sub-class of A (but not of B) var_dump($b);
Output for git.master, git.master_jit, rfc.property-hooks
object(B)#1 (1) { ["instOfParent"]=> object(A)#2 (0) { } } object(B)#1 (1) { ["instOfParent"]=> object(A)#3 (0) { } } object(B)#1 (1) { ["instOfParent"]=> object(C)#2 (0) { ["instOfParent"]=> uninitialized(parent) } } object(B)#1 (1) { ["instOfParent"]=> object(Beta)#3 (0) { } }

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:
52.4 ms | 402 KiB | 8 Q