W3docs

Checking if a variable is an integer in PHP

In PHP, you can use the is_int() function to check if a variable is an integer.

In PHP, you can use the is_int() function to check if a variable is an integer.

Example:

Example of using the is_int() function to check if a variable is an integer in PHP

php— editable, runs on the server
Info

Watch a video course: Learn object oriented PHP

You can also use is_integer() which is an alias of is_int().

Example of using the is_integer() function to check if a variable is an integer in PHP

php— editable, runs on the server