xxxxxxxxxx
Booleans can be one of two constants:
true
false
These values are not case sensitive, therefore true is the same as TRUE
booleans are also often used in control structures, either directly or as
a result of an operation. For example:
if ($waterDrankToday > 3.7) {
echo "Good work staying hydrated!";
if ($havingABadDay)
hug();
}
else
echo "You should drink more water";
xxxxxxxxxx
$value = "true"; // The value you want to convert to boolean
// Using boolval()
$convertedValue = boolval($value);
var_dump($convertedValue); // Output: bool(true)
// Using type casting
$convertedValue = (bool) $value;
var_dump($convertedValue); // Output: bool(true)