3v4l.org

run code in 300+ PHP versions simultaneously
<?php class cA { /** * Test property for using direct default value */ protected static $item = 'Foo'; /** * Test property for using indirect default value */ protected static $other = 'cA'; public static function method() { print self::$item."\r\n"; // It prints 'Foo' on everyway... :( print self::$other."\r\n"; // We just think that, this one prints 'cA' only, but... :) } public static function setOther($val) { self::$other = $val; // Set a value in this scope. } } class cB extends cA { /** * Test property with redefined default value */ protected static $item = 'Bar'; public static function setOther($val) { self::$other = $val; } } cB::setOther('cB'); // It's cB::method()! cB::method(); // It's cA::method()!
Output for git.master, git.master_jit, rfc.property-hooks
Foo cB

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:
46.98 ms | 401 KiB | 8 Q