-1

I want to display some PHP in my HTML page using Alex Gorbatchev SyntaxHighlighter plugin.

My problem is that some code is interpreted by browser as I don't want to (just want to dispay it as plain text)

Code can be found there http://codepen.io/hugsbrugs/pen/OPEyZZ

And the error I'm trying to get rid of is :

Failed to load resource: the server responded with a status of 404 (Not Found)

SOLUTION

Thanks to @spender, I ended doing :

<pre class="brush: php">
    <?php
    $code = file_get_contents('FILE_PATH');
    echo htmlentities($code);
    ?>
</pre>

I wish I could have used HEREDOC in PHP instead of storing my code in an external file but considering the use of single and double quotes, I couldn't achieve it ...

hugsbrugs
  • 3,501
  • 2
  • 29
  • 36

1 Answers1

1

So you need to HTML encode the content so the browser does not interpret it as HTML.

http://php.net/htmlentities

spender
  • 117,338
  • 33
  • 229
  • 351