3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UString { private $string = null; public function __construct(string $string) { $this->string = $string; } } echo strlen(new Ustring('Class with __string method !'));
Output for 8.1.18 - 8.1.28, 8.2.5 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string, UString given in /in/5RNUM:13 Stack trace: #0 {main} thrown in /in/5RNUM on line 13
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.17, 8.2.0 - 8.2.4
Fatal error: Uncaught TypeError: strlen(): Argument #1 ($str) must be of type string, UString given in /in/5RNUM:13 Stack trace: #0 {main} thrown in /in/5RNUM on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: strlen() expects parameter 1 to be string, object given in /in/5RNUM on line 13
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Catchable fatal error: Argument 1 passed to UString::__construct() must be an instance of string, string given, called in /in/5RNUM on line 13 and defined in /in/5RNUM on line 7
Process exited with code 255.

preferences:
200.39 ms | 402 KiB | 272 Q