【发布时间】:2013-08-12 15:01:48
【问题描述】:
我有一个 PHP 脚本,它使用 file_get_contents 调用主 PHP 模板(充当 HTML 模板),从中替换几个单词,然后将最终文件另存为目录中的另一个 PHP。
但是主PHP模板本身有include();和require_once();,替换单词后保存的文件不会加载从主模板调用的文件。
保存文件的 HTML 源代码中包含<?php include('file_here'); ?>,但没有包含 file_here 的输出 -- 见图片。
如何调用 file_get_contents();仍然让主模板执行 include();或 require_once(); ?
【问题讨论】:
-
最好的办法是把主模板文件也包括在内,也许在 ob_start/ob_get_clean 块中,然后对结果进行替换。
标签: php include file-get-contents