PHP for the World Wide Web (Visual QuickStart Guide)
I l @ ve RuBoard |
PHP, like Perl and most other programming languages, includes some shortcuts so that you may avoid ugly constructs such as $Tax = $Tax + 1;. When you are in a situation where you need to increase the value of a variable by just one (called an "incremental" adjustment) or decrease the value of a variable by just one (a "decremental" adjustment) you can use "++" or "" accordingly . To increment the value of a variable:
Tip Although functionally it will not matter whether you code $Tax = $Tax + 1; or the abbreviated $Tax++, the latter (using the increment operator) is the more professional and common method.
Tip In Chapter 6, Conditional Statements and Loops, you'll see how the increment operator is commonly used to count through a series of actions.
Tip To decrement a variable, you merely use the subtraction symbol (-) twice instead of the plus sign, like this: $Number; |
I l @ ve RuBoard |