Cast int to boolean PHP

> Cast integer to boolean
> Convert integer to boolean

Description
Cast integer to boolean


$val = (bool)-1;  // true
$val = (bool)0;   // false
$val = (bool)1;   // true
$val = (boolean)0; // false, same as (bool)
Any non-zero value is considered true.

$val = filter_var(1, FILTER_VALIDATE_BOOLEAN); // true
$val = filter_var(0, FILTER_VALIDATE_BOOLEAN); // false

SEE ALSO