RE: Re: Inspiration for a Tombstone.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-06-27 at 09:52 -0500, Boyd, Todd M. wrote:
> > -----Original Message-----
> > From: Jay Blanchard [mailto:jblanchard@xxxxxxxxxx]
> > Sent: Friday, June 27, 2008 8:50 AM
> > To: tedd; php-general@xxxxxxxxxxxxx
> > Subject: RE:  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." :)

I will never do it... it looks ugly, especially when performing multiple
if comparisons on the variable. Additionally, using a little red to
highlight the assignment operator but not the comparison operator works
just as well. Make machines work for you, not the other way around.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux