Correct, “||” means “OR” when used in a conditional statement.
Fun Fact: in karlpcrowly’s example (and in all instances where “||” is used), if a condition ends up as TRUE, it will ignore and not solve all following conditions and simply move onto the code contained in the brackets.
Above, the first condition is TRUE so it will ignore the "$var > 0" condition and just continue on.
So if you need to use "||" try to put the one mostly likely to be solved TRUE for first that way it only has to calculate 1 statement most of the time.
Also, on an irrelevant note, in karlpcrowly's "if" statement, the first condition is not needed as all numbers greater than 1 are greater than 0 as well, so anything that would be TRUE for the fist statement is also TRUE for the 2nd. Just wanted to clear that up for ricky122892 so he isn't potentially confused.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
*May or may not contain any actual "CSS" or "Tricks".