我從http://windows.php.net/downloads/pecl/releases/pthreads/下載的PHP Pthreads dll文件,並使它在php.ini如下:並行線程在PHP
extension=pthreadVC2.dll
extension=php_pthreads.dll
我用下面的示例代碼:
<?php
class AsyncOperation extends Thread
{
public function __construct($arg){
$this->arg = $arg;
}
public function run(){
if($this->arg){
printf("Hello %s\n", $this->arg);
}
}
}
$thread = new AsyncOperation("World");
if($thread->start())
$thread->join();
當我執行代碼我得到以下錯誤:
Fatal error: Class 'Thread' not found in C:\htdocs\threads\AsyncOperation.php on line 2 Call Stack: 0.0008 333464 1. {main}() C:\htdocs\threads\AsyncOperation.php:0
+1爲解決問題後不放棄問題:)。 – 2013-03-27 09:09:34
@Radu Murzea:謝謝。 – Cindrella 2013-03-27 09:17:21
@cindrella好的。你拯救了我的一天。由於VC PHP擴展的構建不匹配,我一直無法工作得到最近4天的PHP線程工作。非常感謝您指出。 – webblover 2014-03-05 05:29:22