0

I have PHP that looks like this:

$func_code = <<<'EOT'
foo1
foo2 '<foo3>'. foo4 . '</div>';
EOT;

echo $func_code;

And the output looks like this:

one_half   
foo1 foo2 ''. foo4 . '';
foo1 foo2 ''. foo4 . '';

As you can see, and are both completely removed. PHP docs claim that nowdoc won't parse anything inside the text block, but its obviously parsing the < and > symbols.

Anyone got an idea how to solve this?

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
JamesHoux
  • 2,999
  • 3
  • 32
  • 50
  • 2
    PHP isn't parsing it; your browser is. If you look at the source code of the page, you'll see that the HTML tags were outputted unchanged. – Casey Chu Jan 05 '13 at 10:51
  • 1
    It’s probably just the browser you are viewing the output with that interprets the HTML. – Gumbo Jan 05 '13 at 10:51
  • 1
    Are you viewing this in a browser: if so, "view source" – Mark Baker Jan 05 '13 at 10:51
  • HAHA! I realized all this just before I checked back and saw all these answers. LOL Its always the little things that get me. – JamesHoux Jan 05 '13 at 10:55

1 Answers1

1

It isn't PHP who's parsing it. It's your browser. Check the page's source.

If you want the browser not to interpret these, send a Content-type header beforehand:

header('Content-type: text/plain'); //This should be placed before any output is sent!
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308