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 = 'mesh';protected static $other = 'ani'; public static function method_set($val1,$val2) { self::$other = "mesh"; self::$item = "ani"; } } //cB::setOther('cB'); // It's cB::method()! cB::method_set(); cB::method(); // It's cA::method()!
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: Too few arguments to function cB::method_set(), 0 passed in /in/CkYQR on line 43 and exactly 2 expected in /in/CkYQR:34 Stack trace: #0 /in/CkYQR(43): cB::method_set() #1 {main} thrown in /in/CkYQR on line 34
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:
35.87 ms | 401 KiB | 8 Q