3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Printable { public function __toString(); } class MyPrintableClass { public $myNumericProperty; public function __construct() { $this->myNumericProperty = 10; } public function __toString() { return 'My numeric property is ' . $this->myNumericProperty; } } function printSomething(string $printable) { echo $printable; } $printable = new MyPrintableClass(); printSomething((string) $printable); printSomething("a real string"); printSomething((string)1234); printSomething((string)1.2); printSomething((string)true);
based on WddK6
Output for 7.0.0 - 7.2.0
My numeric property is 10a real string12341.21
Output for 5.3.18 - 5.6.28
Catchable fatal error: Argument 1 passed to printSomething() must be an instance of string, string given, called in /in/UdIis on line 24 and defined in /in/UdIis on line 19
Process exited with code 255.