3v4l.org

run code in 300+ PHP versions simultaneously
<?php $callable = function() { }; $fp = fopen("php://memory", "r"); var_dump(intval(null)); var_dump(intval([])); var_dump(intval($fp)); var_dump(intval(new stdClass())); var_dump(intval($callable)); var_dump(floatval(null)); var_dump(floatval([])); var_dump(floatval($fp)); var_dump(floatval(new stdClass())); var_dump(floatval($callable)); var_dump(boolval(null)); var_dump(boolval([])); var_dump(boolval($fp)); var_dump(boolval(new stdClass())); var_dump(boolval($callable)); var_dump(strval(null)); var_dump(strval([])); var_dump(strval($fp)); try { var_dump(strval(new stdClass())); } catch (Throwable $t) { echo "\nFATAL " . $t->getMessage(); } try { var_dump(strval($callable)); } catch (Throwable $t) { echo "\nFATAL " . $t->getMessage(); } if ($fp !== false) { fclose($fp); }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
int(0) int(0) int(5) Warning: Object of class stdClass could not be converted to int in /in/O2KY5 on line 11 int(1) Warning: Object of class Closure could not be converted to int in /in/O2KY5 on line 12 int(1) float(0) float(0) float(5) Warning: Object of class stdClass could not be converted to float in /in/O2KY5 on line 17 float(1) Warning: Object of class Closure could not be converted to float in /in/O2KY5 on line 18 float(1) bool(false) bool(false) bool(true) bool(true) bool(true) string(0) "" Warning: Array to string conversion in /in/O2KY5 on line 27 string(5) "Array" string(14) "Resource id #5" FATAL Object of class stdClass could not be converted to string FATAL Object of class Closure could not be converted to string

preferences:
73.05 ms | 403 KiB | 91 Q