php使用ignore_user_abort()函数后,将脚本置于后台运行,此时客户端就没有对脚本的操作权限了,那该如何停止这个脚本呢?
可以用connection_aborted()在你的程序里进行判断是否异常,然后退出程序。
例子如下:
<?php
ignore_user_abort(TRUE);
set_time_limit(0);
while (1) {
if(connection_aborted()) {
break;
}
//其他逻辑操作
sleep(10);
}
?>
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_222.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57