php使用ignore_user_abort()函数后,将脚本置于后台运行,此时客户端就没有对脚本的操作权限了,那该如何停止这个脚本呢?

可以用connection_aborted()在你的程序里进行判断是否异常,然后退出程序。

例子如下:

<?php
ignore_user_abort(TRUE);
set_time_limit(0);

while (1) {
if(connection_aborted()) {
break;
}
//其他逻辑操作
sleep(10);
}

?>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
  • 2022-01-03
  • 2022-12-23
  • 2021-07-15
  • 2021-10-29
  • 2021-04-20
猜你喜欢
  • 2021-11-03
  • 2021-12-31
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-11-20
相关资源
相似解决方案