3v4l.org

run code in 500+ PHP versions simultaneously
<?php interface One { function callme(string $data): void; } interface Two { function callme(int $data): void; } class OneImpl implements One { function callme(string $data): void {} } class TwoImpl implements Two { function callme(int $data): void {} } class BothImpl implements One, Two { /** * @param int|string $data */ function callme($data): void {} } /** * @param "one"|"two"|"both" $switch * @return One|Two */ function getEither(string $switch) { if ($switch === "one") { return new OneImpl(); } if ($switch === "two") { return new TwoImpl(); } return new BothImpl(); } /** * @param One|Two $impl */ function process($impl): void { if ($impl instanceof One && $impl instanceof Two) { echo 'both'; } elseif ($impl instanceof One) { echo 'one'; } elseif ($impl instanceof Two) { echo 'two'; } } process(getEither("one")); process(getEither("two")); process(getEither("both"));
Output for git.master, git.master_jit, rfc.property-hooks
onetwoboth

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:
53.78 ms | 1485 KiB | 4 Q