C语言 c++ php mysql nginx linux lnmp lamp lanmp memcache redis 面试 笔记 ppt 设计模式 问题 远程连接

php常用函数

 

/**
 * http1.1 链接为 keep alive ,多个请求会重复用一个链接
 * 立刻终止请求,返回,脚本继续在后台执行
 * 
 * @param string $endMessage
 */
function endOutput($endMessage){
    ignore_user_abort(true);
    set_time_limit(0);
    header("Connection: close");
    header("Content-Length: ".strlen($endMessage));
    echo $endMessage;
    echo str_repeat("\r\n", 10); // just to be sure
    flush();
}

endOutput("thank for visiting");

// do something

sleep(10);
file_put_contents("e:/song.txt", date("Y-m-d H:i:s")."\r\n", FILE_APPEND);

 

 

 

posted on 2014-03-06 12:29  思齐_  阅读(143)  评论(0编辑  收藏  举报