- var_dump: documentation ( source)
<?php
function add(float $a, float $b): float {
return $a + $b;
}
var_dump(add("1", "1"));
// float(2)
var_dump(add("1", "1foo"));
// PHP Notice: A non well formed numeric value encountered
// float(2)
var_dump((float) "foo");
// float(0)
var_dump(floatval("foo"));
// float(0)
try {
var_dump(add("1", "foo"));
} catch (Throwable $e) {
var_dump($e);
}
// PHP Fatal error: Uncaught TypeError: Argument 2 passed to add() must be of the type float, string given