3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { function test() { echo "hallo"; } function __toString() { echo "ich bin anders"; } } $t = new test(); echo (string)$t;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
ich bin anders Fatal error: Uncaught TypeError: test::__toString(): Return value must be of type string, none returned in /in/ai7RZ:13 Stack trace: #0 /in/ai7RZ(17): test->__toString() #1 {main} thrown in /in/ai7RZ on line 13
Process exited with code 255.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; test has a deprecated constructor in /in/ai7RZ on line 3 halloich bin anders Fatal error: Uncaught Error: Method test::__toString() must return a string value in /in/ai7RZ:17 Stack trace: #0 {main} thrown in /in/ai7RZ on line 17
Process exited with code 255.
Output for 7.4.26
halloich bin anders Fatal error: Uncaught Error: Method test::__toString() must return a string value in /in/ai7RZ:17 Stack trace: #0 {main} thrown in /in/ai7RZ on line 17
Process exited with code 255.
Output for 7.3.32 - 7.3.33
halloich bin anders Recoverable fatal error: Method test::__toString() must return a string value in /in/ai7RZ on line 17
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; test has a deprecated constructor in /in/ai7RZ on line 3 halloich bin anders Recoverable fatal error: Method test::__toString() must return a string value in /in/ai7RZ on line 17
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; test has a deprecated constructor in /in/ai7RZ on line 3 halloich bin anders Catchable fatal error: Method test::__toString() must return a string value in /in/ai7RZ on line 17
Process exited with code 255.
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28
halloich bin anders Catchable fatal error: Method test::__toString() must return a string value in /in/ai7RZ on line 17
Process exited with code 255.
Output for 5.2.0 - 5.2.2
halloich bin anders<br /> <b>Catchable fatal error</b>: Method test::__toString() must return a string value in <b>/in/ai7RZ</b> on line <b>17</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
halloObject id #1
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
halloObject

preferences:
253.27 ms | 402 KiB | 346 Q