词条 | ignore_user_abort |
释义 | 函数说明(PHP 4中,PHP 5中) ignore_user_abort 设置与客户机断开是否会终止脚本的执行。 本函数返回 user-abort 设置的之前的值(一个布尔值)。 函数定义int ignore_user_abort ([ string $value ] ) 参数 描述 setting 可选。如果设置为 true,则忽略与用户的断开,如果设置为 false,会导致脚本停止运行。 提示注释注释:PHP 不会检测到用户是否已断开连接,直到尝试向客户机发送信息为止。简单地使用 echo 语句无法确保信息发送,参阅 flush() 函数。 实例说明例-1 一个的ignore_user_abort()的例子,配合set_time_limit()函数 和一个死循环就可以实现计划任务功能。 <?php // Ignore user aborts and allow the script // to run forever ignore_user_abort (true); set_time_limit (0); 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. ?> |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。