boolval Function in PHP

What is boolval() in PHP?

Explanation

PHP boolval function is used to get a boolean value from the given input value. It returns "true" on success and "false" on failure.

Syntax:


boolval(var_name)

Example :


<?php
echo (boolval(0) ? 'true' : 'false')."<br />";
echo (boolval(28) ? 'true' : 'false')."<br />";
echo (boolval(0.0) ? 'true' : 'false')."<br />";
echo (boolval(4.2) ? 'true' : 'false')."<br />";
?>

Result :

false
true
false
true

PHP Topics


Ask Questions

Ask Question