1. Determine whether PHP is ts or nts version
Check the Thread Safety item through phpinfo();. This item is to check whether it is thread safe. If it is: enabled, generally speaking it should be the ts version, otherwise it is the nts version.
2. Select the version corresponding to pthreads according to the PHP ts ts version
My php version is 5.4.17, so I downloaded the php_pthreads-0.1.0-5.4-ts-vc9-x86.zip file package, where 0.1.0 represents the current pthreads version number, 5.4 is the php version number, and ts is the previously judged php For the corresponding ts and nts versions, vs9 represents the version compiled by Visual Studio 2008 compiler, and the last x86 represents the 32-bit version.
3. Install pthreads extension
Unzip the downloaded php_pthreads-0.1.0-5.4-ts-vc9-x86.zip file package to obtain pthreadVC2.dll and php_pthreads.dll files, put the vc2 file into the same level directory as php.exe, and put php_pthreads.dll into under the extension directory. 1. Modify the php.ini file and add extension=php_pthreads.dll
2. Modify the Apache configuration file httpd.conf and add LoadFile X:/PHP5/pthreadVC2.dll
3. Restart the Apache server
4. Test pthreads extension
<!--?php
class AsyncOperation extends Thread {
public function __construct($arg){
$this--->arg = $arg;
}
public function run(){
if($this->arg){
printf(Hello %s
, $this->arg);
}
}
}
$thread = new AsyncOperation(World);
if($thread->start())
$thread->join();
?>
If you run the above code and get "HelloWorld", it means that the pthreads extension is installed successfully!
http://www.bkjia.com/PHPjc/735894.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/735894.htmlTechArticle1. Determine whether PHP is a ts or nts version. Check the Thread Safety item in it through phpinfo();. This project is Check whether it is thread-safe. If it is: enabled, generally it should be the ts version...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn