X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP FILTER_VALIDATE_INT Filter


PHP Filter Reference 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:

bool(false)


PHP Filter Reference Complete PHP Filter Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook