I'm new to PHP and I recently installed the xampp installer on my computer (includes PHP Ver. 5.2.3) and noticed that only some of the escape sequences work while other don't.
I have found that the following escape sequences don't work on my machine:
\n
\r
\t
However...the \\ , \$ , \" , octal and hex notation sequences work. In addition, the HEREDOC does not work on my computer either.
The following is an example of my test.php code followed by the output:
Code
<?php
echo "I purchsed the \"best\" burger on the planet \n for only \$2 \r while my fried \t Eric\\Erico sat on my chair"."<br>";
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
print $str;
?>
Output
I purchsed the "best" burger on the planet for only $2 while my fried Eric\Erico sat on my chair
Example of string spanning multiple lines using heredoc syntax.
If you know how to fix this problem please help.....
Thanks
Isaac.
Escape Sequences and HEREDOC Problem
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Escape Sequences and HEREDOC Problem
You assume too much. Try to view source or use nl2br().iash wrote:I have found that the following escape sequences don't work on my machine [...] In addition, the HEREDOC does not work on my computer either.
All whitespace in HTML is rendered as one space. Otherwise, we wouldn't be able to format our HTML with tabbing.