当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP安装pthreads多线程扩展教程[windows篇]

PHP安装pthreads多线程扩展教程[windows篇]

2018年09月24日  | 移动技术网IT编程  | 我要评论

一、判断php是ts还是nts版

通过phpinfo(); 查看其中的 thread safety 项,这个项目就是查看是否是线程安全,如果是:enabled,一般来说应该是ts版,否则是nts版。

二、根据php ts ts版选择对应pthreads的版本

 
本人php版本是5.4.17的所以下载php_pthreads-0.1.0-5.4-ts-9-x86.zip文件包,其中0.1.0表示为当前pthreads版本号,5.4为php版本号,ts就是之前判断php对应的ts、nts版,vs9代表是visual studio 2008 compiler编译器编译的,最后的x86代表的是32位的版本。

三、安装pthreads扩展

将下载好的php_pthreads-0.1.0-5.4-ts-vc9-x86.zip文件包解压得到 pthreadvc2.dll和php_pthreads.dll文件,把vc2文件放到php.exe同级目录,把php_pthreads.dll放到扩展目录下。 1、修改php.ini文件 添加extension=php_pthreads.dll
2、修改apache配置文件httpd.conf 添加loadfile x:/php5/pthreadvc2.dll
3、重启apache服务器

四、测试pthreads扩展

arg = $arg;
  }

  public function run(){
    if($this->arg){
      printf(hello %s
, $this->arg);
    }
  }
}
$thread = new asyncoperation(world);
if($thread->start())
  $thread->join();
?>
运行以上代码得到“helloworld”,就说明安装pthreads扩展成功!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网