[英]PHP file is not refreshed after fwrite and fclose
我正在执行以下操作:
$configurationFile = fopen($configurationFilePath, 'w');
$result = fwrite($configurationFile, $newFileContent);
fflush($configurationFile);
fclose($configurationFile);
if ($result) {
echo '<pre>'; var_dump(require('file.php')); die();
...
尽管显示了旧数据,但在编辑器中或刷新页面后,我可以看到新内容。
如何强制PHP在fclose
之后立即看到新文件的内容?
感谢@engvrdr的提示。 问题出在OPcache扩展上,我最终有两种方法:
禁用OPcache:
ini_set('opcache.enable', '0');
我在索引文件的开头写了它,但是可以针对某些特殊情况进行调整
sleep()
使脚本运行更长的时间(相当粗略的解决方案)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.