我的运行环境:
系统:windows10 ,64位
PHP:5.6.8 TS,VC11 ,32位
Apache: 2.0
我安装的是xampp集成环境
pthreads的windows扩展文件下载地址:http://windows.php.net/downloads/pecl/releases/pthreads/
我下载的是2.0.9-5.6-ts-vc11-x86这个版本
安装步骤:
1,将pthreadVC2.dll复制到 XX盘:\xampp\php\
2,将php_pthreads.dll复制到 XX盘:\xampp\php\ext\
3,php.ini添加extension=php_pthreads.dll
4, 修改Apache配置文件httpd.conf 添加LoadFile "XX盘:/xampp/php/pthreadVC2.dll"
5,重启apache
官方测试代码:
<?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(); ?>
时间: 2024-10-13 17:17:23