我有sript PHP具有三個功能是這樣的:執行三個功能同時
public function a($html,$text)
{
//blaa
return array();
}
public function b($html,$text){
//blaa
return array();
}
public function c($html,$text){
//blaa
return array();
}
require_once 'simple_html_dom.php';
$a=array();
$html=new simple_html_dom();
$a=$this->a($html,$text);
$b=$this->b($html,$text);
$c=$this->c($html,$text);
$html->clear();
unset($html);
$a=array_merge($a, $c);
$a=array_merge($a, $b);
a($html,$text)
需要5秒給出結果b($html,$text)
之前需要10秒之前給出結果c($html,$text)
需要12秒給人一種結果
因此,該系統需要27秒geving我一個結果之前之前,但我希望把我的結果在12秒內。我無法使用線程,因爲我的主機不支持線程。我怎麼解決這個問題?
PHP不是多線程語言。要麼運行3個並行的PHP腳本(它們基本上是相互獨立的),或者不得不順序地運行三個dom操作。 –
你真的確定你的服務器能夠更快地爲你提供服務嗎? – jtheman
是的,因爲我打電話給一個傳送網站的每個功能 –