【发布时间】:2015-02-26 11:12:29
【问题描述】:
我想使用 Alex Gorbatchev SyntaxHighlighter 插件在我的 HTML 页面中显示一些 PHP。
我的问题是某些代码被浏览器解释为我不想 (只想以纯文本形式显示)
代码可以在那里找到 http://codepen.io/hugsbrugs/pen/OPEyZZ
我试图摆脱的错误是:
Failed to load resource: the server responded with a status of 404 (Not Found)
解决方案
感谢@spender,我结束了:
<pre class="brush: php">
<?php
$code = file_get_contents('FILE_PATH');
echo htmlentities($code);
?>
</pre>
我希望我可以在 PHP 中使用 HEREDOC,而不是将我的代码存储在外部文件中,但考虑到使用单引号和双引号,我无法实现它......
【问题讨论】:
-
您尝试加载的 JavaScript 文件,例如 agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shCore.js,不存在。使用正确的 URL。
-
您的链接存在...不知道为什么会出错(测试时出现服务器错误...)
-
对我来说仍然是 404..
标签: php html syntaxhighlighter