[nycphp-talk] What's going on here? PHP conditional.
Tim Gales
tgales at tgaconnect.com
Fri Jul 2 11:31:43 EDT 2004
"If the string starts with valid numeric data,
this will be the value used.
Otherwise, the value will be 0 (zero)."
http://us2.php.net/manual/en/language.types.string.php#language.types.stri
ng.conversion
T. Gales & Associates
'Helping People Connect with Technology'
http://www.tgaconnect.com
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org
> [mailto:talk-bounces at lists.nyphp.org] On Behalf Of Brian Kaney
> Sent: Friday, July 02, 2004 11:19 AM
> To: NYPHP Talk
> Subject: [nycphp-talk] What's going on here? PHP conditional.
>
>
> Just came across this problem. Consider the following code:
>
> <?php
>
> echo "Equivalent: ";
> if (0 == 'Some String') { echo 'evaluates true'; } else {
> echo 'evaluates false'; }
>
> echo "\n";
>
> echo "Equivalent and same type: ";
> if (0 === 'Some String') { echo 'evaluates true'; } else {
> echo 'evaluates false'; }
>
> ?>
>
> I get
>
> Equivalent: evaluates true
> Equivalent and same type: evaluates false
>
>
>
> Does anyone know why (0 == 'string') evaluates to true?
>
> According to the manual, the integer 0 converts to FALSE. A
> non-empty (or non-zero) string is considered TRUE. I would
> think if (FALSE ==
> TRUE) should be evaluated as false?
>
> http://us2.php.net/manual/en/language.types.boolean.php#langua
ge.types.boolean.casting
- Brian
_______________________________________________
talk mailing list
talk at lists.nyphp.org http://lists.nyphp.org/mailman/listinfo/talk
More information about the talk
mailing list