Note: . Iterate over the characters of the string, and for each character, use ctype_digit() function to check if the character is a digit or not. FILTER_VALIDATE_INT also allows us to specify a range for the integer variable. // if it's not a string, nor an integer, we freak out and say no. Sometimes it is important to have the value of a variable in int format. I need to check whether a string contains numbers. If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Here is a simple way to do a check that will work: