is_int()By using is_int function we can check integer number in PHP. This function returns True of false ( Boolean variable ) based on the data. Here is an simple example
For True output is 1 , For False no output will be generated.
Difference between is_numeric and is_intif the variable stores integer as string that then is_int() will return false. Here is an example.
Above code will say this is not an integer
But in above case is_numeric will identify this as an integer. Note that if we are using any form data as input then all numeric data also treated as string. Here is an example.
We can create an form to post data to the above code like this
In the above form if we post an integer then also is_int will return false.
This article is written by plus2net.com team.
| ▼ Web Forms & handling data in PHP