manalnor Posted September 27, 2010 Share Posted September 27, 2010 hello friends, that would help me alot , if i've 2 code all are of if and else code 1 $r = $_SERVER['HTTP_REFERER'];if (stripos($r, $refere) !== false) {echo "good";}else{echo "bad";} code 2 if($line[hits] >= $limited){echo "bad";}else{echo "good";} both are 2 codes where the user should pass before it show good how then it be 1 code not 2 ( if x if y else y2 else x2 ) it like double sandwich Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 27, 2010 Share Posted September 27, 2010 This: if (stripos($r, $refere) !== false && $line['hits'] < $limited) {echo "good";}else{echo "bad";} Or this: if (stripos($r, $refere) === false || $line['hits'] >= $limited) {echo "bad";}else{echo "good";} Quote Link to comment Share on other sites More sharing options...
rwwd Posted September 27, 2010 Share Posted September 27, 2010 if (stripos($r, $refere) !== false) { Careful with the use of !== this can produce unexpected results... It's a lot easier to use != unless your certain that the evaluated items are of the same type (int, char, string, object) Other than that, not sure what your trying to achieve. From abracadaver's suggestion:- if ((stripos($r, $refere) === false) || ($line['hits'] >= $limited)) { Just parenthesize the evaluated parts of either side of the conditional || just because it's easier to read.. Rw Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 27, 2010 Share Posted September 27, 2010 if (stripos($r, $refere) !== false) { Careful with the use of !== this can produce unexpected results... It's a lot easier to use != unless your certain that the evaluated items are of the same type (int, char, string, object) Other than that, not sure what your trying to achieve. Rw The intent is to see if a string is found in another string by returning the position of the match or false if no match. If the string is found in the other string at position 0 then using 0 != false will evaluate to false, whereas 0 !== false evaluates to true. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.