Validate Value as Integer in PHP
Simple PHP function that checks if the variable $int is a valid integer number. The function below returns true also if the $int variable is 0:
function is_valid_integer($int) { return (filter_var($int, FILTER_VALIDATE_INT) === 0 || filter_var($int, FILTER_VALIDATE_INT) !== FALSE) ? true : false; } |
More information:
http://php.net/manual/en/filter.filters.validate.php
More Related Posts
- [2016/05/19] Check if a String Contains Multiple Wo...
- [2016/06/04] Check if a Number is Multiple of Anoth...
- [2016/06/07] How to Get File Extension in PHP
- [2016/05/20] Turn Off Expose_PHP (Hide X-Powered-By...
- [2016/05/26] How to Increase PHP Memory Limit
- [2016/05/25] Disable PHP Notice: Undefined variable...
- [2016/05/27] PHP Domain Parser: Domain\URL Parser P...
- [2016/05/19] Remove Non-Alphanumeric Characters fro...