第一问题:ignore_user_abort这个函数是不是一定要在PHP.INI里设置成为ON才能运行?
第二个问题:如果第一个问题回答是必需要设置的话,那么ignore_user_abort这个函数还有没有其它的方法让其运行。
最后,我要实现的功能是:让用户关闭浏览器,这个.PHP文件也能正常运行。
下面是PHP的代码。有谁可以指点下的。
<?php
ignore_user_abort(true);
set_time_limit(0);
function test(){
$hosts = array("http://www.baidu.com", "http://www.google.com", "http://www.qq.com");
$timeout = 15;
$status = array();
$sockets = array();foreach ($hosts as $id => $host) {
$s = stream_socket_client("$host:80", $errno, $errstr, $timeout);
if ($s) {
mail("[email protected]","bad connect","progress not in");
} else {
mail("[email protected]","success connect","progress in");
}
}
}function do_cron(){
usleep(150000000);
test();
}while(1){
do_cron();
}
?>
第二个问题:如果第一个问题回答是必需要设置的话,那么ignore_user_abort这个函数还有没有其它的方法让其运行。
最后,我要实现的功能是:让用户关闭浏览器,这个.PHP文件也能正常运行。
下面是PHP的代码。有谁可以指点下的。
<?php
ignore_user_abort(true);
set_time_limit(0);
function test(){
$hosts = array("http://www.baidu.com", "http://www.google.com", "http://www.qq.com");
$timeout = 15;
$status = array();
$sockets = array();foreach ($hosts as $id => $host) {
$s = stream_socket_client("$host:80", $errno, $errstr, $timeout);
if ($s) {
mail("[email protected]","bad connect","progress not in");
} else {
mail("[email protected]","success connect","progress in");
}
}
}function do_cron(){
usleep(150000000);
test();
}while(1){
do_cron();
}
?>
2、ignore_user_abort(true);
3、不知道你遇到了什么问题按你给出的代码,如在 web 方式下运行时,是会有问题的!
因为你的代码没有输出
一般 http 服务器在约定的时间间隔中没有检测到应用程序的输出时,将视为连接超时而强制终止由他创建的进(线)程