The escape-sequence replacements in PHP
The escape-sequence replacements are:
\
- \n is replaced by the newline character
- \r is replaced by the carriage-return character
- \t is replaced by the tab character
- \$ is replaced by the dollar sign itself ($)
- \" is replaced by a single double-quote (")
- \\ is replaced by a single backslash (\)
Here Document:
You can assign multiple lines to a single string variable using here document:
<?php $channel =<<<_XML_ <channel> <title>What's For Dinner</title> <link>http://menu.example.com/<link> <description>Choose what to eat tonight.</description> </channel> _XML_; echo <<<END This uses the "here document" syntax to output multiple lines with variable interpolation. Note that the here document terminator must appear on a line with just a semicolon. no extra whitespace!
END; print $channel; ?>
This will produce following result:
This uses the "here document" syntax to output multiple lines with variable interpolation. Note that the here document terminator must appear on a line with just a semicolon. no extra whitespace! <channel> <title>What's For Dinner</title> <link>http://menu.example.com/</link> <description>Choose what to eat tonight.</description>
The escape-sequence replacements in PHP
Reviewed by Rajat Jha
on
20:11:00
Rating:
No comments: