php装扩展多钱程pthreads

来源:互联网 发布:新疆广电网络上市辅导 编辑:程序博客网 时间:2024/05/23 01:59

前提: pthreads下载页面:  http://windows.php.NET/downloads/pecl/releases/pthreads/

在下载时要对对应自己的php版本和位数来下载


php_pthreads-2.0.9-5.3-ts-vc9-x86

上面这个对应的就是

 pthreads 版本为2.09的

php版本为5.3的

ts 为线程安全的(在windows下载用ts的 linux下才是用nts)

vc9 就是编译器MSVC9 (Visual C++ 2008)

X86 对应的就是32位


下载解压:

一.提取

1. php_pthreads.dll

2. pthreadVC2.dll


二.文件放的位置

1. php_pthreads.dll 放在php/ext/的目录下

2. pthreadVC2.dll 放在php根目录下

3. pthreadVC2.dll 放在apache根目录下


三.php中加载模块

php.ini 中加入

extension=php_pthreads.dll


四.测试代码

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();  

输出

Hello World 


或用 

<?php

phpinfo();

 ?>

来查看是否加载进来