3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Use //+overloaded to enable method overloading class A {} class B {} class Overloaded { protected $value; //+overloaded function setValue(A $x) { $this->value = $x; } //+overloaded function setVаlue(B $x) { $this->value = $x; } function dump() { var_dump("The value =", $this->value); } } $something = new Overloaded(); $something->setValue(new A); $something->dump(); $something->setVаlue(new B); $something->dump();
based on hitd8
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.1.7
string(11) "The value =" object(A)#2 (0) { } string(11) "The value =" object(B)#3 (0) { }