It's important to note the difference between using "=" and "==" in your conditional statements. They're not interchangeable. An if statement evaluates the expression to its boolean value and executes the code accordingly.
A single '=' will assign the variable the value to the right so:
PHP Code:
if ($browser['browser'] = 'IE') {
Becomes:
Which will evaluate to true.
A '==' will compare the value to the left with the value to the right to see if they are equal. If they are equal, it evaluates as true, otherwise it evaluates to false.
Using OR (or '||') in your if statement will tell PHP to return true if either of these statements are true. As soon as PHP sees it's first statement that is true, it will stop testing anything else in the if statement.
So if your statement looks like this:
PHP Code:
if (($browser['browser'] = 'IE') && ($browser['version'] < 9) || ($browser['browser'] = 'Firefox') && ($browser['version'] < 3.5) || ($browser['browser'] = 'Opera') && ($browser['version'] < 7) || ($browser['browser'] = 'Safari') && ($browser['version'] < 3))
As long as the browser version is less than 9, it will return true because $browser['browser'] = 'IE' will always evaluate as true. The only time the above example would return false is if the browser version is >= 9.
The only times using '=' will evaluate as false is when the value to the right evaluates as "" (empty string), false, null, 0, or array() (an empty array).
Hope that helps some.
Bookmarks