1 Answers
In PHP 7 we can add Scalar types like int, float, string, and bool.
By adding scalar type hints and enabling strict requirements, we can write more corrected and self-documenting PHP programs. It also gives us more control over our code and can make the code easier to read.
Strict Example:-
function getSUM(float $a, float $b) { return $a + $b; } getSUM(5, "2 day"); // you will get a 'Notice: A non well formed numeric value encountered' getTotal(3.9, '5.1'); // string '5.1' changed to float(3.9) no notice //returns float(9)
Your Answer