Why ‘false’ == true is 1?

You are asking PHP to compare two different things.

a "string" against a boolean.

This comes up a lot in PHP so it has a built in set of rules how to convert between two different kinds of value.

Usually, it has to convert the more complicated thing to the simpler thing to compare them.

In this case, the complicated "string" (that can have many values) needs to be converted to a boolean (which only has two values).

If you think about a string in its simplest terms, it can only have two values: Empty or not empty. Empty is false, not empty is true

So behind the scenes, PHP evaluates your question as:

(not empty string is true) is the same as (true)

Which is true!

If you:
echo true;

The answer is 1.

/r/PHPhelp Thread