【发布时间】:2017-06-13 08:31:20
【问题描述】:
我得到了简单的缓存脚本,它将 php 代码保存到 HTML 中。一切正常,但我需要将动态跟踪代码添加到每个保存的 HTML 中,方法是使用 include() 语句包含来自另一个文件的脚本
....
$s_getdata = http_build_query( array(
'cat' => 'CAT1',
'buffit'=>'TRUE',
)
);
$s_page = file_get_contents('http://example.com/buffer.php?'.$s_getdata);
ob_start();
echo $s_page;
file_put_contents('./index.html', ob_get_contents());
ob_end_clean();
我尝试在 ob_start 之前添加此代码,但它只是将代码作为字符串中的简单文本添加(不起作用):
$s_page .= '<?php include("./tr/in.php"); ?>';
知道怎么做吗?谢谢!
【问题讨论】:
-
php 不会在 .html 文件中执行。
./tr/in.php中的内容也许你可以做一个 file_get_contents 如果它只是 html 或者再次做缓冲捕获