PHP is_bool() function

By using this function, we can check whether the variable is boolean variable or not.

Syntax

snippet
bool is_bool ( mixed $var )

Parameters

Parameter Description Is compulsory
var_name The variable being evaluated. compulsory

Returns

It return True if var is boolean, False otherwise.

Example 1

snippet
<?php
	$x=false;
	echo is_bool($x);
?>

Output:

PHP Variable Handling is_bool() function

Example 2

snippet
<?php
	$y=false;
	if (is_bool($y))
	echo 'This is a boolean type.';
	else
	echo 'This is not a boolean type.';
?>

Output:

PHP Variable Handling is_bool() function
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +