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

php计划任务之ignore_user_abort函数实现方法,ignoreuserabort

本文实例讲述了php计划任务之ignore_user_abort函数实现方法。分享给大家供大家参考。具体分析如下:

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() 函数.

希望本文所述对大家的php程序设计有所帮助。

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

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.