0

Hey..
I wonder what's the difference between the use of || and OR
I have an example:

$Assumed_Variable = 1;
$Assumed_Query = mysql_query("select something from someTable",$connection);
if($Assumed_Variable == 1 || mysql_num_rows($Assumed_Query) > 0){
  echo 'Success!';
}
else{
  echo 'Failure!';
}

So, if I understand this issue, this means that the code above will apparently print "Success!", but the parser will first look at the second part of the condition because the precedence is its.
However, have I put OR instead of ||, then the parser will check the first part of the condition, and, since it's true, it'll not look at the second part. And this way is faster because it won't take time using the function Mysql_num_rows().
Am I right in all of this?
Thank you.

5
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Pro2000
1

The IF statement will still compare everything. The only difference between "||" and "OR" is that "AND" is calculated before "OR" but after "||".

Votes + Comments
Thank you.
-1

usually || is used as an operator for the comparison of two or more BOOLEAN statements. The OR is used for comparison of two or more ERROR HANDLING statements.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.