I noticed PHP is_numeric()
accepts "E" as a number.
I have a string: "88205052E00
" and I want the result to be: NOT numeric.
Here is the code which I tested.
<?php
$notnumber = '88205052E00';
if(is_numeric($notnumber)) {
echo $notnumber . ' is a number';
} else {
echo $notnumber . ' is NOT a number';
}
?>
The Code above gives result:
88205052E00 is a number
How can I get the result to be: 88205052E00 is NOT a number?
I will keep the answer incase it helps but as pointed out there are shortcomings with ctype_digit
in that it does not like -
or .
.
More likely then you want to use ctype_digit which checks if all of the characters in the provided string, text, are numerical.
Where as is_numeric — Finds whether a variable is a number or a numeric string
<?php
$s = "88205052E00";
if(ctype_digit($s)){
echo "Yes";
} else {
echo "No";
}
returns no.