我有一个PHP文件,基于某些参数返回HTML,但它也保存在一个单独的目录(基本上是一个自定义的缓存过程)这个输出。PHP:“运行”文件/脚本而不是包含?
现在我想建立一个单独的php文件,它基于已知可能参数的数组自动更新缓存。
所以我想要“加载”或“运行”而不是“包含”文件多次使用不同的参数,以便它将结果保存在缓存文件夹中。
是否有一个PHP函数,可以让我简单地加载这个其他文件,也许告诉我什么时候完成?如果没有,我是否需要使用ajax来做这样的事情,或者也许PHP的curl库?
目前我在想沿着以下的说法:
<?php
$parameters = array("option1", "option2", "option3");
//loop through parameters and save to cache folder
foreach ($parameters as $parameter){
//get start time to calculate process time
$time_start = microtime(true);
sleep(1);
//I wish there was some function called run or load similar to jquery's 'load'
run("displayindexsearch.php?p=$parameter");
//return total time that it took to run the script and save to cache
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Process Time: {$time} seconds";
}
?>