3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Enable overloading using //+overloaded class A {} class B {} class Overloaded { protected $value; //+overloaded function setValue(integer $x) { $this->value = 'a'; } //+overloaded function setVаlue(boolean $x) { $this->value = 'b'; } function dump() { var_dump("The value =", $this->value); } } $something = new Overloaded(); $something->setValue(666); $something->dump(); $something->setVаlue(true); $something->dump(); $something->setVаlue([]); $something->dump();
Output for git.master, git.master_jit, rfc.property-hooks
Warning: "integer" will be interpreted as a class name. Did you mean "int"? Write "\integer" to suppress this warning in /in/fuBHq on line 12 Warning: "boolean" will be interpreted as a class name. Did you mean "bool"? Write "\boolean" to suppress this warning in /in/fuBHq on line 17 Fatal error: Uncaught TypeError: Overloaded::setValue(): Argument #1 ($x) must be of type integer, int given, called in /in/fuBHq on line 30 and defined in /in/fuBHq:12 Stack trace: #0 /in/fuBHq(30): Overloaded->setValue(666) #1 {main} thrown in /in/fuBHq on line 12
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:
62.12 ms | 402 KiB | 8 Q