I started learning PHP to do some pet project, and I am trying to get this around my head on how to validate a valid float or double in PHP
Supposed I have this code in HTML that ask for interest rate
<input type="text" name="interest" size="5" >
In My PHP code, I wanted to validate if this is a valid interest rate:
<?php
$interest = $_POST['interest']
//isset - empty test (not- shown)
if(!is_numeric($interest) && is_float($interest)){
print "<p><span class='error'>Interest should be numeric</span></p>";
}
?>
I have my is_numeric() test first then I coupled it with the is_float() test but when I enter "1." (note the "." after the number) it should catch this but apparently not. I am not sure why "1." is a valid floating variable in PHP.