How to use FILTER VALIDATE BOOLEAN in PHP

This article describe about FILTER_VALIDATE_BOOLEAN Filter in PHP.
  • 2122

FILTER_VALIDATE_BOOLEAN Filter

For validates value as a Boolean option FILTER_VALIDATE_BOOLEAN Filter used.

  • Name: "boolean"
  • ID-number: 258

Possible return values:

  • Returns FALSE for "0", "false", "off" and "no"
  • Returns TRUE for "1", "true", "on" and "yes"
  • Returns NULL otherwise.

Example

<html>
<body>
<?php
$var="yes";
var_dump(filter_var($var, FILTER_VALIDATE_BOOLEAN));
?>
</body>
</html>

Output

filtervalidatebooleanphp.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.