Why does PHP output "nocookie" when the variable is assigned 0 in the if statement?

When PHP evaluates a variable with a value of 0 in an if statement, it treats it as a false value. This is because PHP considers 0 to be a falsy value. To output "nocookie" when the variable is assigned 0 in the if statement, you can explicitly check if the variable is equal to 0 using the strict comparison operator (===).

$cookies = 0;

if ($cookies === 0) {
    echo "nocookie";
} else {
    echo "cookie";
}