Example 1 — Converting Common Values
Pass a few everyday values to boolval() and print the result with var_dump().
<?php
var_dump(boolval(1));
var_dump(boolval(0));
var_dump(boolval("hello"));
var_dump(boolval("")); How It Works
- boolval(1) is true, because any number other than zero is truthy.
- boolval(0) is false, because zero is falsy.
- A non-empty string such as "hello" is true.
- An empty string is false. var_dump() prints bool(true) or bool(false) so you can see the exact type.

