PHP FILTER_VALIDATE_INTFilter
Complete PHP Filter Reference Manual
Definition and Usage
The FILTER_VALIDATE_INT filter validates a value as an integer.
- Name: "int"
- ID-number: 257
Possible options or flags:
- min_range - Specifies the minimum integer value
- max_range - Specifies the maximum integer value
- FILTER_FLAG_ALLOW_OCTAL - Allows octal values
- FILTER_FLAG_ALLOW_HEX - Allows hexadecimal values
Tips and Notes
Notes:When specifying options in an array, the options must be placed in an associative multidimensional array named "options". See the example below.
Example
<?php
$var=300;
$int_options = array("options"=>
array("min_range"=>0, "max_range"=>256));
var_dump(filter_var($var, FILTER_VALIDATE_INT, $int_options));
?>
$var=300;
$int_options = array("options"=>
array("min_range"=>0, "max_range"=>256));
var_dump(filter_var($var, FILTER_VALIDATE_INT, $int_options));
?>
The output of the code is as follows:
bool(false)
Complete PHP Filter Reference Manual Other Extensions