The following script never runs the 'else' part of the code, but I don't understand why. Any thoughts appreciated.
if(is_numeric($mortgage))
{
$table =
"
<table width='100%' border='0' cellpadding='1'>
<tr>
<td class='warning'><div align='center'>That's a number!</div></td>
</tr>
</table>
";
} else {
$table =
"
<table width='100%' border='0' cellpadding='1'>
<tr>
<td class='warning'><div align='center'>Mortgage number field must contain numbers ONLY</div></td>
</tr>
</table>
";
}
is_numeric issue
Moderator: General Moderators
Re: is_numeric issue
Code: Select all
var_dump($mortgage);PHP Manual wrote: is_numeric
Finds whether the given variable is numeric. Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal notation (0xFF) is allowed too but only without sign, decimal and exponential part.
Re: is_numeric issue
Thanks.
I found the problem to be elsewhere in the code. To try and test the input I had $mortgage.length instead of strlen($mortgage), so a test failed upon which my code above replied.
Switching between programming languages causes memory failure some days!
I found the problem to be elsewhere in the code. To try and test the input I had $mortgage.length instead of strlen($mortgage), so a test failed upon which my code above replied.
Switching between programming languages causes memory failure some days!