How to use FILTER VALIDATE INT in PHP

This article describe about FILTER_VALIDATE_INT Filter in PHP.
  • 3868

FILTER_VALIDATE_INT Filter

For validate value as integer FILTER_VALIDATE_INT Filter used.

  • Name: "int"
  • ID-number: 257

Possible options and flags:

  • FILTER_FLAG_ALLOW_OCTAL - octal number values allows
  • FILTER_FLAG_ALLOW_HEX -hexadecimal number values allows
  • min_range - define the minimum integer value
  • max_range - define the maximum integer value
     

Example

<html>
<body>
<?php
$var=400;
$int_options = array("options"=>
array("min_range"=>0, "max_range"=>256));
var_dump(filter_var($var, FILTER_VALIDATE_INT, $int_options));
?>
</body>
</html>

Output

filtervalidateintphp.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.