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.

Tell your friends about this post on Facebook and Twitter

Sorry, comments disabled and hidden due to excessive spam.

Meanwhile, hit me up on twitter @stoyanstefanov