3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { function __toString() { return '42'; } } var_dump(round(new Foo, 2));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, Foo given in /in/14uHo:9 Stack trace: #0 /in/14uHo(9): round(Object(Foo), 2) #1 {main} thrown in /in/14uHo on line 9
Process exited with code 255.
Output for 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Object of class Foo could not be converted to number in /in/14uHo on line 9 float(1)
Output for 7.3.32, 7.4.26
float(1)

preferences:
98.44 ms | 1381 KiB | 4 Q