PHP | is_numeric() Function Last Updated : 05 Feb, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The is_numeric() function is an inbuilt function in PHP which is used to check whether a variable passed in function as a parameter is a number or a numeric string or not. The function returns a boolean value. Syntax: bool is_numeric ( $var ) Parameters: The function accepts a single parameter which is mandatory and described below: $var: This input parameter is the variable which the function checks for whether it is a number or a numeric string. Based on this verification, the function returns a boolean value. Return Value: The function returns TRUE if $var is a number or a numeric string and returns FALSE otherwise. Examples: Input : $var = 12 Output : True Input : $var = "Geeks for Geeks" Output : False Below programs illustrate the is_numeric() function: Program 1: In this program, a number is passed as input. PHP <?php $num = 12; if (is_numeric($num)) { echo $num . " is numeric"; } else { echo $num . " is not numeric"; } ?> Output: 12 is numeric Program 2: In this program, a string is passed as input. PHP <?php $element = "Geeks for Geeks"; if (is_numeric($element)) { echo $element . " is numeric"; } else { echo $element . " is not numeric"; } ?> Output: Geeks for Geeks is not numeric Program 3: In this program, a numeric string is passed as input. PHP <?php $num = "467291"; if (is_numeric($num)) { echo $num . " is numeric"; } else { echo $num . " is not numeric"; } ?> Output: 467291 is numeric Program 4: PHP <?php $array = array( "21/06/2018", 4743, 0x381, 01641, 0b1010010011, "Geek Classes" ); foreach ($array as $i) { if (is_numeric($i)) { echo $i . " is numeric"."\n"; } else { echo $i . " is NOT numeric"."\n"; } } ?> Output: 21/06/2018 is NOT numeric 4743 is numeric 897 is numeric 929 is numeric 659 is numeric Geek Classes is NOT numeric Reference: http://php.net/manual/en/function.is-numeric.php Comment More infoAdvertise with us Next Article Lodash _.isNumber() Function R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP is_long() Function The is_long() function is an inbuilt function in PHP that is used to check whether the given value is a long integer or not. Syntax: bool is_long(mixed $value) Parameters: This function accepts a single parameter $value that holds the value which needs to check for a long integer. Return Value: This 1 min read PHP is_integer() Function The is_integer() function is an inbuilt function in PHP that is used to check whether the type of a variable is an integer or not. This function is an alias of is_int() function. Syntax: bool is_integer(mixed $value) Parameters: This function accepts a single parameter $value that holds the value wh 1 min read Lodash _.isNumber() Function Lodash _.isNumber() method is used to find whether the given value parameter is a number or not. If the given value is a number then it returns True value otherwise, it returns False.Syntax:_.isNumber(value); Parameters:value: This parameter holds the value to check.Return Value: This method returns 2 min read PHP Math Functions PHP is a scripting language that comes with many built-in math functions and constants. These tools help you do basic math, solve more complex problems, and work with different math concepts. This guide gives an overview of PHP's math functions and constants, along with examples, practical uses, and 5 min read PHP octdec( ) Function In the earlier days of computing, octal numbers and the octal numbering system was very popular for counting inputs and outputs because as it works in counts of eight, inputs and outputs were in counts of eight, a byte at a time. Due to a wide usage of octal number system many times it happens that 2 min read PHP mb_encode_numericentity() Function The mb_encode_numercentity() function is an inbuilt function in PHP that is used to encode HTML entities with numerical values encoded using either decimal or hexadecimal representation. Syntax: string mb_encode_numericentity( string $string, array $map, string $encoding, bool $hex )Parameters: This 2 min read Like