However, if you view the source, you??™ll see that the output in fact appears on
two separate lines. The same idea holds true if the data were output to a text file.
In addition to the newline character, PHP recognizes a number of special escape
sequences, all of which are listed in Table 3-14.
Single Quotes
Enclosing a string within single quotes is useful when the string should be interpreted
exactly as stated. This means that both variables and escape sequences will not be
interpreted when the string is parsed. For example, consider the following singlequoted
string:
print 'This string will $print exactly as it\'s \n declared.';
Table 3-14. Recognized Escape Sequences
Sequence Description
\n Newline character
\r Carriage return
\t Horizontal tab
\\ Backslash
\$ Dollar sign
\" Double quote
\[0-7]{1,3} Octal notation
\x[0-9A-Fa-f]{1,2} Hexadecimal notation
CHAPTER 3 ?– PHP BASICS 97
This produces the following:
This string will $print exactly as it's \n declared.
Note that the single quote located in it's was escaped. Omitting the backslash
escape character will result in a syntax error, unless the magic_quotes_gpc configuration
directive is enabled. Consider another example:
print 'This is another string.\\';
This produces the following:
This is another string.\
In this example, the backslash appearing at the conclusion of the string has to be
escaped; otherwise, the PHP parser would understand that the trailing single quote
was to be escaped.
Pages:
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182