- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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