PHP for the World Wide Web (Visual QuickStart Guide)
I l @ ve RuBoard |
The next logical formation after an if conditional is the if-else (sometimes called the if-then-else ) conditional. This allows you to establish a condition as to why one statement would be executed and then another statement which would be executed if that condition is not met. if (condition) { statement(s); } else { statement(s)2; } The important thing to remember when using this construct is that unless the condition is explicitly met, the else statement will be executed. In other words, the statements after the else constitute the default action while the statements after the if condition are the exception to the rule. You can now rewrite the numbers .php page incorporating else into the if statement. To use else:
Tip You could also, at this time, add an if-else conditional to numbers.php so that a message is printed if the discount does apply. Or, if you want to be very particular, you could use an if-else conditional to print the singular "widget" if only one widget is ordered but the plural "widgets" otherwise (as opposed to "widget(s)"as I've been writing).
|
I l @ ve RuBoard |