Databases Reference
In-Depth Information
produces the result:
Not equal to 33: []
The false result is displayed as an empty string.
<
Tests whether the first value is less than the second:
print "Less than 33: [". $TemperatureToday <33. "]\n";
produces the result:
Less than 33: []
>
Tests whether the first value is greater than the second:
print "Greater than 33: [". $TemperatureToday >33. "]\n";
produces the result:
Greater than 33: []
<=
Tests whether the first value is less than or equal to than the second:
print "Less than or equal to 33: [". $TemperatureToday<=33. "]\n";
produces the result:
Less than or equal to 33: [1]
>=
Tests whether the first value is greater than or equal to the second:
print "Greater than or equal to 33: [". $TemperatureToday>=33. "]\n";
produces the result:
Greater than or equal to 33: [1]
Operator precedence
The instructions we've looked at so far have been simple, with only one operator. What
happens if we have complex expressions with multiple operators? For example, what's
the the value of answer after this statement is executed?
$answer=1+2-3*4/5;
You may remember from your high school math that mathematical operators have an
order of precedence : multiplication and division are performed before addition and
subtraction. However, relying on the order of precedence can try your memory, and
your code will be hard to read. Parentheses override the order of precedence, allowing
you to be sure that expressions will be evaluated as you expect. Our example would
actually be evaluated as:
 
Search WWH ::




Custom Search