PHP FILTER_VALIDATE_INT Filter
Complete PHP Filter Reference
Definition and Usage
The FILTER_VALIDATE_INT filter validates value as integer.
- Name: "int"
- ID-number: 257
Possible options and flags:
- min_range - specifies the minimum integer value
- max_range - specifies the maximum integer value
- FILTER_FLAG_ALLOW_OCTAL - allows octal number values
- FILTER_FLAG_ALLOW_HEX - allows hexadecimal number values
Tips and Notes
Note: When specifying options in an array. The options must be in an
associative multidimensional array with the name "options". See 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));
?>
|
The output of the code will be:
Complete PHP Filter Reference
Want To Be A Web Master?
If you want to be a Web Master, you will have to host your web site with an ISP (Internet Service Provider).
MaximumASP offers seven different configurations of dedicated servers to meet your Windows and .NET hosting needs.
Hosted on our multi-tiered Enterprise Class network, these servers provide the performance, security and reliability
you need to host your high end web sites and applications.
Visit MaximumASP
|