booleans casted to strings

March 15th, 2005. Tagged: PHP certification

What happens when a false value is casted to a string?

I.e. what is the result of the following:
< ?php var_dump((string)false); ?>

The answer is:
string(0) ""

This is good to know and expect when using some string functions that sometimes return a string and sometimes a boolean. Such functions are strstr(), strpos(), etc.

Comments? Find me on BlueSky, Mastodon, LinkedIn, Threads, Twitter