3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); class Test { function __toInt() { return 10; } function __toFloat() { return 10.00; } function __toString() { return "10"; } } var_dump((int) new Test, (float) new Test, (string) new Test);
based on r2ERX
Output for 7.0.0 - 7.2.0
Notice: Object of class Test could not be converted to int in /in/IXYG7 on line 19 Notice: Object of class Test could not be converted to float in /in/IXYG7 on line 19 int(1) float(1) string(2) "10"
Output for 5.3.20 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/IXYG7 on line 3 Notice: Object of class Test could not be converted to int in /in/IXYG7 on line 19 Notice: Object of class Test could not be converted to double in /in/IXYG7 on line 19 int(1) float(1) string(2) "10"