Re: Comparison style
| From: | Brian Moon | Date: | Tue, 15 May 2001 03:14:21 +0000 |
| Subject: | Re: Comparison style | ||
| References: | 1 | Groups: | php.dev php.pear.dev |
| Request: | Send a blank email to pear-dev+get-382@lists.php.net to get a copy of this message | ||
There is another reason as well.
type casting is done right to left. This will always ensure that the
variables type is compared to "", which will convert to 0 if $content is a
number.
Not sure if this was intentional or not, but it is true.
Brian Moon
----------------------------------------------------------------------
dealnews.com, Inc.
Makers of dealnews, dealmac
http://dealnews.com/ | http://dealmac.com/
----- Original Message -----
From: "Jon Parise" <jon@csh.rit.edu>
To: <pear-dev@lists.php.net>; <php-dev@lists.php.net>
Sent: Monday, May 14, 2001 9:31 PM
Subject: [PEAR-DEV] Comparison style
> I was just perusing some of the PEAR code, and a certain
> condition caught my eye:
>
> if ("" == $content)
>
> My habit has always been to write that sort of condition using
> the style:
>
> if ($content == "")
>
> (leaving the unknown value on the left side of the comparison
> operator)
>
> Is one of these styles preferable to the other, either always or
> in certain instances?
>
> --
> Jon Parise (jon@csh.rit.edu) . Rochester Inst. of Technology
> http://www.csh.rit.edu/~jon/ : Computer Science House Member
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, e-mail: pear-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: pear-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>