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: Facebook, Twitter, Google+

Sorry, comments disabled and hidden due to excessive spam. Working on restoring the existing comments...

Meanwhile, hit me up on twitter @stoyanstefanov