By the use of curl_multi_init() (PHP5) or stream_select() (PHP5) or pcntl_fork (PHP4+), we can stimulate multi-thread/multi-process environment on PHP
External Links:
using stream_select: Develop multitasking applications with PHP V5
using curl_multi_init: PHP curl_multi example of parallel GET requests
using pcntl_fork (chinese): 多采多姿的程式筆記#1, #2
forum quote(chinese): EcStart PHP 技術討論論壇
PHP是與host環境相關的腳本語言,通常狀況下不會使用thread的,有的話也是host的問題,與php沒有關係。(你用的話,會有同步等等問題,甚至會有可能造成host運作不穩定)
但是如果把php當作shell script等等獨立的語言工具來用的話,是可以模擬的。
php本身應該沒有提供thread的函數,但是有multi-process的吧。
請用google找找。
我在酷學園有看過一些討論:
http://phorum.study-area.org/index.php/topic,44942.0.html
http://phorum.study-area.org/index.php/topic,47238.0.html(這篇有提到一點同步機制)另外,參考一下這一篇:
http://www.ibm.com/developerworks/web/library/os-php-multitask/?ca=dgr-lnxw06PHP5multitasking
(用php5模擬多工)
