There are two such operators, including the concatenation operator (.)
and the concatenation assignment operator (.=) discussed in the previous section.
?– Note To concatenate means to combine two or more objects together to form one single entity.
Here is an example involving string operators:
// $a contains the string value "Spaghetti & Meatballs";
$a = "Spaghetti" . "& Meatballs";
$a .= " are delicious."
// $a contains the value "Spaghetti & Meatballs are delicious."
The two concatenation operators are hardly the extent of PHP??™s string-handling
capabilities. Read Chapter 9 for a complete accounting of this important feature.
Increment and Decrement Operators
The increment (++) and decrement (--) operators listed in Table 3-8 present a minor
convenience in terms of code clarity, providing shortened means by which you can
add 1 to or subtract 1 from the current value of a variable.
Table 3-7. String Operators
Example Label Outcome
$a = "abc"."def"; Concatenation $a is assigned the string abcdef
$a .= "ghijkl"; Concatenation-assignment $a equals its current value
concatenated with ???ghijkl???
Table 3-8. Increment and Decrement Operators
Example Label Outcome
++$a, $a++ Increment Increment $a by 1
--$a, $a-- Decrement Decrement $a by 1
92 CHAPTER 3 ?– PHP B ASICS
These operators can be placed on either side of a variable, and the side on which
they are placed provides a slightly different effect.
Pages:
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177