ignore_user_abort 设置与客户机断开是否会终止脚本的执行。 本函数返回 user-abort 设置的之前的值(一个布尔值)。 int ignore_user_abort ([ string $value ] ) 参数 描述 setting 可
ignore_user_abort 设置与客户机断开是否会终止脚本的执行。
本函数返回 user-abort 设置的之前的值(一个布尔值)。
int ignore_user_abort ([ string $value ] )
参数 | 描述 | ||||
setting | 可选。如果设置为 true,则忽略与用户的断开,如果设置为 false,会导致脚本停止运行。
|
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
123 45 11 14 1516 17 18 19 20
24 |
例-1 一个的ignore_user_abort()的例子,配合set_time_limit()函数 和一个死循环就可以实现计划任务功能。
echo 'Testing connection handling in PHP' ; // Run a pointless loop that sometime // hopefully will make us click away from // page or click the "Stop" button. while (1) { // Did the connection fail? if ( connection_status () != CONNECTION_NORMAL ) { break ; } // Sleep for 10 seconds sleep (10); } // If this is reached, then the 'break' // was triggered from inside the while loop // So here we can log, or perform any other tasks // we need without actually being dependent on the // browser. ?>
|
1 |
int ignore_user_abort ( [ bool setting] )
|
123 | <?php ignore_user_abort(); ?> |
说明:调用ignore_user_abort()函数声明即使客户机断开不终止脚本的执行。
2,结合set_time_limit()函数实现一个循环脚本执行任务
?
3 4
7 8 |
set_time_limit(0);
$interval=60*15; do {
//执行的业务
|
说明:每隔15分钟循环执行
3,自定义实现文件输出并跟踪ignore_user_abort()函数的执行结果?123456789101112 | <?php ignore_user_abort ( TRUE ); set_time_limit ( 0 ); $interval = 10; $stop = 1; do { if ( $stop == 10 ) break ; file_put_contents( 'liuhui.php' , ' Current Time: ' .time(). ' Stop: ' .$stop); $stop ; sleep ( $interval ); } while ( true ); ?> |

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

记事本++7.3.1
好用且免费的代码编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

WebStorm Mac版
好用的JavaScript开发工具