To fully understand this concept,
you need at least an introductory knowledge of the binary representation of decimal
integers. Table 3-12 presents a few decimal integers and their corresponding binary
representations.
The bitwise operators listed in Table 3-13 are variations on some of the logical
operators but can result in drastically different outcomes.
If you are interested in learning more about binary encoding and bitwise operators
and why they are important, check out Randall Hyde??™s massive online reference, ???The
Art of Assembly Language Programming,??? available at http://webster.cs.ucr.edu/.
Table 3-12. Binary Representations
Decimal Integer Binary Representation
2 10
5 101
10 1010
12 1100
145 10010001
1,452,012 101100010011111101100
Table 3-13. Bitwise Operators
Example Label Outcome
$a & $b AND And together each bit contained in $a and $b
$a | $b OR Or together each bit contained in $a and $b
$a ^ $b XOR Exclusive-or together each bit contained in $a and $b
~ $b NOT Negate each bit in $b
$a << $b Shift left $a will receive the value of $b shifted left two bits
$a >> $b Shift right $a will receive the value of $b shifted right two bits
CHAPTER 3 ?– PHP BASICS 95
String Interpolation
To offer developers the maximum flexibility when working with string values, PHP
offers a means for both literal and figurative interpretation. For example, consider the
following string:
The $animal jumped over the wall.
Pages:
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180