On 25 July 2004 21:16, Skippy wrote:

 
> Any idea why the need to have two logical operators with the
> same meaning BUT
> different precedences? I dig the need to put in OR as an
> alias, but why
> confuse people with the precedence issue? One would tend to
> think || and OR
> are perfectly interchangeable.

It's a horses for courses situation -- each tends to lead to better readability when 
used in its appropriate context.  For instance (to improve on the above example):

   $result = mysql_query(.....) or die(mysql_error());

would need extra parentheses if rewritten using the || operator:

   ($result = mysql_query(.....)) || die(mysql_error());

On the other hand, a construct like:

   $is_valid = $x>0 || $y>0;

would need additional parentheses with or:

   $is_valid = ($x>0 or $y>0);

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

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

Reply via email to