3v4l.org

run code in 300+ PHP versions simultaneously
<?php class number { public function __toString() { return '32.29'; } } $obj = new number(); var_dump($obj); var_dump($obj / 1.21); var_dump((string)$obj / 1.21);
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
object(number)#1 (0) { } Fatal error: Uncaught TypeError: Unsupported operand types: number / float in /in/VFo9o:12 Stack trace: #0 {main} thrown in /in/VFo9o on line 12
Process exited with code 255.
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
object(number)#1 (0) { } Notice: Object of class number could not be converted to number in /in/VFo9o on line 12 float(0.82644628099174) float(26.685950413223)
Output for 7.3.32 - 7.3.33
object(number)#1 (0) { } float(0.82644628099174) float(26.685950413223)
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
object(number)#1 (0) { } Notice: Object of class number could not be converted to int in /in/VFo9o on line 12 float(0.82644628099174) float(26.685950413223)

preferences:
106.17 ms | 1965 KiB | 4 Q