【发布时间】:2010-06-18 19:58:03
【问题描述】:
我正在尝试 file_get_contents 并将 php 代码输出为字符串 而没有 被呈现。这个想法是获取原始的未渲染文件内容,以便可以在文本区域中编辑它们......
// file "foo.php" I'm needing the contents of
<h1>foo</h1>
<? include 'path/to/another/file' ?>
// php file that's calling the file_get_contents
<?php
echo file_get_contents('foo.php');
?>
上面的代码去掉了 foo.php 中的 php 包含输出:
<h1>foo</h1>
有谁知道我如何将 foo.php 内容作为未渲染的原始字符串获取到输出位置?:
<h1>foo</h1>
<? include 'path/to/another/file' ?>
非常感谢任何帮助!
【问题讨论】:
-
您是否查看了结果源以确保内容真的消失了?
-
你所做的应该有效。我能想到的唯一会失败的情况是,如果您将 foo.php 作为 URL (domain/foo.php) 访问...
-
噢!好的,它显示在源代码中但不在 DOM 中??
-
维克多,是的,这是一个本地文件。
-
Charles,有没有办法让 php 代码字符串显示在 DOM 中?
标签: php