127.0.0.1/a.php
set_time_limit(0);
while (true) {
file_put_contents('./a', "data\r\n", FILE_APPEND);
sleep(1);
}
我关闭浏览器后为什么发现a文件还在写啊,我删了a文件还是会继续生成,不是说关闭连接后PHP默认终止脚本吗?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
是使用
nginx + php还是apache + php,还是其他webserver + phpnginx + php,严格的说是phpfpm + php的确会出现这个情况但是前提是你对
ignore_user_abort()函数是否设置为false,如果为true,那么当用户关闭浏览器后,php页面还会继续执行!同时发现你对页面设置了set_time_limit(0),就是说脚本不会超时!只要调整ignore_user_abort()就好了