3v4l.org

run code in 300+ PHP versions simultaneously
<?php class StringCastable { private $data; public function __construct(string $data) { $this->data = $data; } public function __toString(): string { return $this->toString(); } public function toString(): string { return $this->data; } } function testStringCast(string $data) { var_dump($data, get_class($data)); } $speculoos = new StringCastable("speculoos"); var_dump($speculoos); testStringCast($speculoos);
Output for git.master, git.master_jit, rfc.property-hooks
object(StringCastable)#1 (1) { ["data":"StringCastable":private]=> string(9) "speculoos" } Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, string given in /in/5926B:25 Stack trace: #0 /in/5926B(32): testStringCast('speculoos') #1 {main} thrown in /in/5926B on line 25
Process exited with code 255.

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:
60.44 ms | 401 KiB | 8 Q