[PHP-DEV] Comparison style

2001-05-14 Thread Jon Parise

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 ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Comparison style

2001-05-14 Thread Sterling Hughes

Jon Parise wrote:

 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?
 
 

It depends on your personal style.   The reason for testing like:

if ( == $content)

Is because, if you're careless enough to have only one '=' sign:

if ( = $content)

The code will not fail silently, but rather emit and error, whereas:

if ($content = )

Will fail silently, and might therefore cause debugging headaches later on.

-Sterling


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]