You are here: Re: How to perform conditional? « PHP Programming Language « IT news, forums, messages
Re: How to perform conditional?

Posted by Erwin Moller on 11/06/06 09:29

MsKitty wrote:

> Hi Brett -
> You have unbalanced parentheses - one extra one on the left = try
> using fewer ones so it is easier to see:
> if (is_page() || $category->cat_ID === $cat) {
> do something
> }


Correct, but advising to drop parentheses is not a good advise.
Use it everywhere, and use it right.
Dropping parentheses leads to possible confusion because tests can be
performed in a order not ment by the programmer.

I prefer this notation above all shorter ones:

if ((is_page()) || ($category->cat_ID === $cat) ) {
do something
}

That way you don't have to worry about precedence of the used terms.
eg: Is || or === evaluated first?

just my 2 cent...

Regards,
Erwin Moller

>
> Kitty
> http://OpenSkyWebDesign.com
>
> brett wrote:
>> I'd like to check these two conditions:
>>
>> if ((is_page() or ($category->cat_ID === $cat)){
>> do something
>> }
>>
>> but keep getting an "unexpected {..." error. If I do this, it works
>> fine:
>>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация