如何在php中检测客户端断开连接。我有一个使用nusoap库的Web服务,我想检测Web服务客户端断开连接。 我尝试使用此代码:
ignore_user_abort(true); // Continue running the script even when the client aborts/disconnects
ob_flush();
flush(); // Clean PHP's output buffer
usleep(500000);
echo "0\r\n\r\n";
ob_flush(); // Clean output buffer
flush(); // Clean PHP's output buffer
if(connection_aborted() != 0) {
//do something
}
它有效但有2个问题:
如何解决上面列出的问题?还有其他方法可以检测Web服务客户端断开连接吗? 感谢