PHP boolval() function

In this chapter you will learn:

  1. Description for PHP boolval function
  2. Syntax for PHP boolval function
  3. Parameter for PHP boolval function
  4. Return value for PHP boolval function
  5. Example - What is the boolean value for converted from real value

Description

PHP boolval function returns the boolean value of var.

Syntax

PHP boolval function has the following syntax.

boolean boolval ( mixed $var )

Parameter

PHP boolval function has the following parameter.

  • var - The scalar value being converted to a boolean.

Return

Returns the boolean value of var.

Example

What is the boolean value for converted from real value.


<?php/*from   j ava  2  s.c  o  m*/
echo '0:        '.(boolval(0) ? 'true' : 'false')."\n";
echo '4:        '.(boolval(4) ? 'true' : 'false')."\n";
echo '0.0:      '.(boolval(0.0) ? 'true' : 'false')."\n";
echo '4.2:      '.(boolval(4.2) ? 'true' : 'false')."\n";
echo '"":       '.(boolval("") ? 'true' : 'false')."\n";
echo '"string": '.(boolval("string") ? 'true' : 'false')."\n";
echo '"0":      '.(boolval("0") ? 'true' : 'false')."\n";
echo '"1":      '.(boolval("1") ? 'true' : 'false')."\n";
echo '[1, 2]:   '.(boolval([1, 2]) ? 'true' : 'false')."\n";
echo '[]:       '.(boolval([]) ? 'true' : 'false')."\n";
?>

Next chapter...

What you will learn in the next chapter:

  1. Description for PHP floatval() function
  2. Syntax for PHP floatval() function
  3. Parameter for PHP floatval() function
  4. Return value for PHP floatval() function
  5. Example - Get the float value
Home » PHP Tutorial » PHP Data Type Functions
PHP boolval() function
PHP floatval() function
PHP gettype() function
PHP intval() function
PHP is_array(value) function
PHP is_bool() function
PHP is_float() function
PHP is_int() function
PHP is_null() function
PHP is_numeric() function
PHP is_object() function
PHP is_resource() function
PHP is_string() function
PHP isset() function
PHP settype() function
PHP strval() function