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:
>>
[Back to original message]
|