3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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();
based on UXPB5
Output for 7.3.0alpha1
Fatal error: Uncaught TypeError: Argument 1 passed to Overloaded::setValue() must be an instance of 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.
Output for 7.0.0 - 7.2.6
Fatal error: Uncaught TypeError: Argument 1 passed to Overloaded::setValue() must be an instance of integer, integer 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.
Output for 5.6.0 - 5.6.29
Catchable fatal error: Argument 1 passed to Overloaded::setValue() must be an instance of integer, integer given, called in /in/fuBHq on line 30 and defined in /in/fuBHq on line 12
Process exited with code 255.