3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B {} class Overloaded { protected $value; function setValue(A $x) { print __METHOD__ . '(A)' . PHP_EOL; $this->value = $x; } function setVаlue(B $x) { print __METHOD__ . '(B)' . PHP_EOL; $this->value = $x; } } $something = new Overloaded(); $something->setValue(new A); var_dump($something); $something->setVаlue(new B); var_dump($something);
Output for git.master, git.master_jit, rfc.property-hooks
Overloaded::setValue(A) object(Overloaded)#1 (1) { ["value":protected]=> object(A)#2 (0) { } } Overloaded::setVаlue(B) object(Overloaded)#1 (1) { ["value":protected]=> object(B)#3 (0) { } }

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:
52.03 ms | 2018 KiB | 4 Q