包括文件获取上次更改的新内容



我创建了一个名为"settings.php";

和内部设置.pp

<?php 
return '123'; 
?>

在index.php中,我使用file_put_contents 更新了settings.php的内容

$config = '1234';
file_put_contents('settings.php', '<?php return ' . var_export($config), true) . ';');

成功更新内容后,在index.php中,我调用settings.php

$config = include(BASEPATH.'settings.php');

但是在我打印_r之后,结果是

123

在有时等待(可能5到15秒(后,我再次刷新页面,内容更改为

1234

问题是,为什么我刷新页面后更新的内容没有直接更改?如何在我更改内容后从settings.php获取最新更新的内容。

通过phpinfo((检查服务器上的缓存解决方案。

然后您可以搜索解决方案。

首先,如果您的服务器上安装了opcache解决方案,您可以尝试以下操作:

if (function_exists('opcache_invalidate')) {
opcache_invalidate('second.php');//Reset file cache
}

或者对于普通的原始文件:

clearstatcache();

最新更新