我已经从http://windows.php.net/downloads/pecl/releases/pthreads/下载了PHP Pthreads dll 文件,并在 php.ini 中启用了它,如下所示:
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();
当我执行代码时,出现以下错误:
致命错误:在第 2 行的 C:\htdocs\threads\AsyncOperation.php 中找不到类“线程”调用堆栈:0.0008 333464 1. {main}() C:\htdocs\threads\AsyncOperation.php:0