Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
FILTER_VALIDATE_BOOLEAN constant in PHP
The FILTER_VALIDATE_BOOLEAN constant validates value as a boolean option.
Return
The FILTER_VALIDATE_BOOLEAN constant returns TRUE for "1", "true", "on" and "yes". It returns FALSE for "0", "false", "off" and "no" otherwise, NULL.
Example
<?php $var="on"; var_dump(filter_var($var, FILTER_VALIDATE_BOOLEAN)); ?>
Output
The following is the output.
bool(true)
Example
Let us see another example.
<?php $var="off"; var_dump(filter_var($var, FILTER_VALIDATE_BOOLEAN)); ?>
Output
Here is the output.
bool(false)
Advertisements
