RE: [PHP] Re: Inspiration for a Tombstone.
| From: | Boyd, Todd M. | Date: | Fri, 27 Jun 2008 14:52:48 +0000 |
| Subject: | RE: [PHP] Re: Inspiration for a Tombstone. | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276059@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Jay Blanchard [mailto:jblanchard@pocket.com]
> Sent: Friday, June 27, 2008 8:50 AM
> To: tedd; php-general@lists.php.net
> Subject: RE: [PHP] Re: Inspiration for a Tombstone.
>
> [snip]
> And being dyslexic, I knew the 'Dan S' should have come first, but
> didn't immediately recognize it as I was rushing to point out a
> double equal-sign boo-boo made by Col.
> [/snip]
>
> Had Col used the method we're speaking of here the error would have
> been
> thrown and he would have found the culprit post haste.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
I think you guys are missing something: he wrote it with single equals
signs on purpose. He was demonstrating how the one with the constant to
the right of the assignment operator is a valid statement... and that
putting the constant first will aid you in finding such mistakes.
if("constant" = $variable){} // bombs, and lets you know right away you
missed an =
if($variable = "constant"){} // assigns rather than compares, but
nonetheless is valid code
To quote Colin: "As I very humorously hinted at in a earlier mail on
this thread, it is a very, very good idea to get into the habit of
putting constants *first* in if/while/etc statements." So, I'm sure he
is well familiar with this "method we're speaking of." :)
Todd Boyd
Web Programmer