search
Homephp教程php手册php计划任务之ignore_user_abort函数实现

php计划任务之ignore_user_abort函数实现

Jun 13, 2016 am 11:26 AM
ignorephpuserTaskfunctionaccomplishdisconnectDetectionuserplan

PHP 不会检测到用户是否已断开连接,直到尝试向客户机发送信息为止。简单地使用 echo 语句无法确保信息发送,参阅 flush() 函数。

 代码如下 复制代码

 ignore_user_abort(true);
 set_time_limit(0);
 
 while(1) {
   $fp  = fopen('time_task.txt',"a+");
   $str = date("Y-m-d h:i:s")."nr";
   fwrite($fp,$str);
   fclose($fp);
   sleep(5);    //半小时执行一次
 }
 ?>


定义和用法
ignore_user_abort() 函数设置与客户机断开是否会终止脚本的执行。

本函数返回 user-abort 设置的之前的值(一个布尔值)。

语法
ignore_user_abort(setting)参数 描述
setting 可选。如果设置为 true,则忽略与用户的断开,如果设置为 false,会导致脚本停止运行。

如果未设置该参数,会返回当前的设置。
 
提示和注释
注释:PHP 不会检测到用户是否已断开连接,直到尝试向客户机发送信息为止。简单地使用 echo 语句无法确保信息发送,参阅 flush() 函数。

 

这里有一篇文章大家可以参考一下

http://www.bkjia.com/phper/php/php-ignore_user_abort.htm


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!