如果要设置成只有 10 个进程来处理$urls 数组,应该怎么做?
<?php
header("Content-Type: text/html;charset=utf-8");
class DuoXianCheng extends Thread {
public function __construct($arg){
$this->arg = $arg;
}
public function run(){
if($this->arg){
// echo $this->result = $this->arg;
$this->result = model_http_curl_get($this->arg);
}
}
}
$thread = new DuoXianCheng("World");
if($thread->start()){
$thread->join();
}
function model_http_curl_get($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)');
$result = curl_exec($curl);