只返回false的函数不返回[重复]

This question already has an answer here:

function return_true () {
    return true;
}

function return_false () {
    return false;
}

echo return_true(); //outputs 1
echo return_false(); //outputs nothing

why can't I echo out return_false and get 0 ? Apologies if this has been asked before but I didn't find anything that answers this question. Note: I am not saying this is something that needs to be done, I was just messing around with bools in PHP and found this odd.

</div>

Use var_dump() instead of echo and you will get your desired result.

echo will output a string and a boolean false echoed as a string will always be nothing / empty

if you want to check with your return type you can check with php function var_dump()

echo var_dump(return_true()); //outputs 1
echo var_dump(return_false()); //outputs nothing

it will print

OUTPUT

bool(true) 
bool(false)