I have an if statment with two conditions (seperated by an OR operator), one of the conditions covers +70% of situations and takes far less time to process/execute than the second condition, so in the interests of speed i only want the second condition to be processed if the first condition evaluates to false.
if i order the conditions so that the first condition (the quicker one) appears in the if statment first - on the occasions where this condition is met and evaluates true is the second condition even processed ?
if ( (condition1) | (condition2) ){
// do this
}
or would i need to nest two if statements to only check the second condition if the first evaluates to false ?
if (condition1){
// do this
}else if (condition2){
// do this
}
I am working in php, however i assume that this may be language-agnostic.
Thanks