3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo { public function out(string $msg) { print __CLASS__ . ': ' . $msg . PHP_EOL; } } class Msg { public function __toString() { return "world"; } } class Bar extends Foo { public function out($msg) { print __CLASS__ . ': ' . $msg . PHP_EOL; } } $f = new Foo(); try { $f->out('hello'); } catch (TypeError $e) { print $e->getMessage() . PHP_EOL; } try { $f->out(new Msg()); } catch (TypeError $e) { print $e->getMessage() . PHP_EOL; } $b = new Bar(); try { $b->out('hello'); } catch (TypeError $e) { print $e->getMessage() . PHP_EOL; } try { $b->out(new Msg()); } catch (TypeError $e) { print $e->getMessage() . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
Foo: hello Foo::out(): Argument #1 ($msg) must be of type string, Msg given, called in /in/0dpsJ on line 34 Bar: hello Bar: world

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:
28.38 ms | 405 KiB | 5 Q