Answers for "php check if only number in string"

PHP
7

check if string is number or not php

$var_num = "1";
$var_str = "Hello World";

var_dump( is_numeric($var_num), is_numeric($var_str) );

/* 
Output -
 bool(true)
 bool(false)
*/
Posted by: Guest on April-15-2020
3

how to check number only in php

## CHECK IF INPUT IS NUMBER ONLY
$number = "12345";
is_numeric($number); ## RETURNS TRUE IF NUMBER ONLY, ELSE FALSE
Posted by: Guest on April-09-2022

Code answers related to "php check if only number in string"

Browse Popular Code Answers by Language