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(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 Nc397

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Arrow functions
string(11) "The value =" object(A)#2 (0) { } string(11) "The value =" object(B)#3 (0) { }
Output for Object typehint
string(11) "The value =" object(A)#2 (0) { } string(11) "The value =" object(B)#3 (0) { }
Output for Array change keys
string(11) "The value =" object(A)#2 (0) { } string(11) "The value =" object(B)#3 (0) { }
Output for Lexical anon
string(11) "The value =" object(A)#2 (0) { } string(11) "The value =" object(B)#3 (0) { }
Output for Typed properties
string(11) "The value =" object(A)#2 (0) { } string(11) "The value =" object(B)#3 (0) { }

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