3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo {} class Bar { public function firstTypeError ($passed) { $trace = debug_backtrace(); throw new TypeError(__CLASS__ . "::" . __FUNCTION__ . "(): Argument #1 (\$passed) elements must be of type " . Baz::class . ", " . get_debug_Type($passed) . " given, called in " . $trace[0]["file"] . " on line " . $trace[0]["line"]); } public function secondTypeError ($passed) { $trace = debug_backtrace(); throw new TypeError(__CLASS__ . "::" . __FUNCTION__ . "(): Argument #1 (\$passed) elements must be of type " . Baz::class . ", " . get_debug_Type($passed) . " given"); } } class Baz {} $bar = new Bar(); try { $bar->firstTypeError("test"); } catch (TypeError $e) { echo $e->__toString(); } echo "\n\n\n\n"; try { $bar->secondTypeError("test"); } catch (TypeError $e) { echo $e->__toString(); }
Output for git.master_jit, git.master, rfc.property-hooks
TypeError: Bar::firstTypeError(): Argument #1 ($passed) elements must be of type Baz, string given, called in /in/vR4M1 on line 22 and defined in /in/vR4M1:8 Stack trace: #0 /in/vR4M1(22): Bar->firstTypeError('test') #1 {main} TypeError: Bar::secondTypeError(): Argument #1 ($passed) elements must be of type Baz, string given in /in/vR4M1:13 Stack trace: #0 /in/vR4M1(30): Bar->secondTypeError('test') #1 {main}

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.27 ms | 406 KiB | 5 Q