W3Schools.com

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
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE