2013-01-23 31 views
1

我在Codeigniter PHP Framework中製作Web應用程序。 當用戶點擊登錄按鈕,有被服務儀表盤用戶Codeigniter中的並行編程

防爆

/*When user clicks login button */ 
$this->setSession($u_id); 
$this->getUserData($u_id); 
$this->getUserFriends($u_id); 
$this->sendEmail($u_id); 
$this->showDashboard($data); 

之前調用函數5-6現在上述四個功能獨立functions..they不互動彼此以任何方式。因此,如果這3個函數以任意順序執行或並行執行,系統仍然處於一致模式。

那麼我怎麼能讓這3個函數在Codeigniter中同時執行呢?

在此先感謝

+0

「平行」 ...好! – swatkins

回答

2

PHP不支持後臺進程,但檢查此變通辦法: http://ellislab.com/forums/viewthread/66539/#327527

function background() { 
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30); 
if (!$fp) { 
    log_message('error', 'Unable to connect to server'); 
    return; 
} 
$request = "GET /SendSMS/index HTTP/1.1\r\n" 
    ."Host: www.example.com\r\n" 
    ."Connection: Close\r\n\r\n"; 
fwrite($fp, $request); 
fclose($fp); 
}