【发布时间】:2011-10-31 05:31:05
【问题描述】:
我正在使用file_get_contents() 来合并模板和分离内容并将它们一起输出为一个页面。
我遇到的问题是,如果这些文件中的任何一个有 PHP 语句,
<?php
echo "example";
?>
PHP 并未实际运行,该语句似乎只是标记的一部分:
起初我以为我正在加载的文件中的 PHP 不会先运行,但后来我用以下内容制作了一个测试页面:
<?php
echo file_get_contents("http://stackoverflow.com");
?>
还有uploaded it here to see that it works fine(首先处理PHP)。
我应该使用不同的功能吗?
【问题讨论】:
-
你可能意味着文件函数php.net/manual/en/function.file.php
-
Problem when loading php file into variable (Load result of php code instead of the code as a string) 的可能重复项 - 这只是同一个问题,您可能会在它的各种答案中找到一些更有用的提示。