PHP头条
热点:

pthreads多线程数据采集


以前使用curl的多线程并不是真正的多线程,只是一种模拟的多线程,现在使用pthreads来实现真正意义上的多线程。

下载:

  windows下:

    http://windows.php.net/downloads/pecl/releases/pthreads/0.0.45/

  mac、unix、linux下:

    https://github.com/krakjoe/pthreads

  windows下:

    解压得到pthreadVC2.dll和php_pthreads.dll文件,把vc2文件放到php.exe同级目录,把php_pthreads.dll放到扩展目录下。

    修改php.ini文件 添加extension=php_pthreads.dll

    修改Apache配置文件httpd.conf 添加LoadFile "yourpath/php/pthreadVC2.dll"

  mac、unix、linux下:

    具体可参考宴哥的博客http://blog.s135.com/pthreads/

调用方式:

  具体的用法也可以参考宴哥的博客http://blog.s135.com/pthreads/

  结合以前的get_html也可以这样来实现类

  threads         = ''       =        
       __construct(,  =          ->url =          ->options =   
               (!(->             ->data = ->get_html(->url, ->   
       get_html(, =          ((             [CURLOPT_RETURNTRANSFER] =              [CURLOPT_TIMEOUT] = 5           = curl_init(         curl_setopt_array(,          = curl_exec(         curl_close(         ( ===                            }

 

 

www.phpzy.comtrue/php/5799.htmlTechArticlepthreads多线程数据采集 以前使用curl的多线程并不是真正的多线程,只是一种模拟的多线程,现在使用pthreads来实现真正意义上的多线程。 下载: windows下: http://windows.php.net/downloads/pe...

相关文章

相关频道:

PHP之友评论

今天推荐