PHP安裝threads多執行緒擴充基礎教學
一、下載pthreads擴充
下載網址:http://windows.php.net/downloads/pecl/releases/pthreads
二、判斷PHP是ts還是nts版
透過其中的Thread(); 查看其中的Thread Safety 項,這個項目就是要查看是否是執行緒安全,如果是:enabled,一般來說應該是ts版,否則是nts版。
三、根據PHP tsnts版選擇對應pthreads的版本
本人php版本是5.4.17的所以下載php_pthreads-0.1.0-5.4-ts-vc9-x86.zip檔包,其中0.1.0表示為目前pthreads版本號,5.4為php版本號,ts就是先前判斷php對應的ts、nts版,vs9代表是Visual Studio 2008 compiler編譯器編譯的,最後的x86代表的是32位元的版本。
四、下載pthreads擴充
下載網址:http://windows.php.net/downloads/pecl/releases/pthreads
五、安裝pthreads
複製php_pthreads.phpdext 到目錄下目錄 到目錄
複製php_pthreads。
複製pthreadVC2.dll 到目錄 binphp 下面。
複製pthreadVC2.dll 到目錄 C:windowssystem32 下面。
開啟php設定檔php.ini。在後面加上extension=php_pthreads.dll
<?php class Thread { var $hooks = array(); var $args = array(); function thread() { } function addthread($func) { $args = array_slice(func_get_args(), 1); $this->hooks[] = $func; $this->args[] = $args; return true; } function runthread() { if(isset($_GET['flag'])) { $flag = intval($_GET['flag']); } if($flag || $flag === 0) { call_user_func_array($this->hooks[$flag], $this->args[$flag]); } else { for($i = 0, $size = count($this->hooks); $i < $size; $i++) { $fp=fsockopen($_SERVER['HTTP_HOST'],$_SERVER['SERVER_PORT']); if($fp) { $out = "GET {$_SERVER['PHP_SELF']}?flag=$i HTTP/1.1rn"; $out .= "Host: {$_SERVER['HTTP_HOST']}rn"; $out .= "Connection: Closernrn"; fputs($fp,$out); fclose($fp); } } } } }
include('thread.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();

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)