[nycphp-talk] Casting string "false" to boolean
Dell Sala
dell at sala.ca
Sun Apr 29 09:58:59 EDT 2007
On Apr 29, 2007, at 9:26 AM, Jakob Buchgraber wrote:
> I'd like to cast a string "false" to a boolean.
> So is there a way to cast such a string to a boolean (without using
> conditions)?
The string "false" will evaluate to true, any way you slice it. The
only strings that evaluate to false are "" and "0".
http://www.php.net/manual/en/language.types.boolean.php
I suppose you could eval the string... But you should think hard
before doing this. I can't image a justification for it. If you're
getting input for a false value as "false" you should really use some
kind of conditional statement.
-- Dell
More information about the talk
mailing list