個人運行環境:php
系統:windows10 ,64位apache
PHP:5.6.8 TS,VC11 ,32位windows
Apache: 2.0 測試
我安裝的是xampp集成環境this
pthreads的windows擴展文件下載地址:http://windows.php.net/downloads/pecl/releases/pthreads/spa
我下載的是2.0.9-5.6-ts-vc11-x86這個版本.net
安裝步驟:code
1,將pthreadVC2.dll複製到 XX盤:\xampp\php\blog
2,將php_pthreads.dll複製到 XX盤:\xampp\php\ext\io
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(); ?>