Validate an integer with PHP
Free Scripts :: PHP :: Validation :: Validate an integer with PHP
Author: Salman Javaid
Website: http://www.salman.be
Website: http://www.salman.be
- Validate a number value with php.
- How to validate an integer with php.
- Validate a number value with php.
Function accepts a parameter and returns false if value is not an integer.
Function
function isValidInteger($string){
if(!preg_match("/^[0-9]+$/",$string)){
return false;
}
}
Calling The Function
$string=5;
if(isValidInteger($string)!==false){
echo 'Value is an integer';
}else{
echo 'Value is not an integer';
}
Output
Value is an integer




