码迷,mamicode.com
首页 > 编程语言 > 详细

PHP异步调用多线程

时间:2016-06-22 12:24:04      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

$data["name"] = ‘godlike‘;
$data["age"] = 18;
$post = http_build_query($data);
$len = strlen($post);

$host = "www.example.com";
$path = "/member/lackGoods/sendSmsAll";
$errno =‘‘;
$errstr=‘‘;
$fp = fsockopen($host,80,$errno,$errstr,30);
if (!$fp) {
echo "$errstr ($errno)\n";
} else {

$out = "POST $path HTTP/1.1\r\n"; //通过POST方式
$out .= "Host: $host\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Connection: Close\r\n";
$out .= "Content-Length: $len\r\n";
$out .= "\r\n";
$out .= $post . "\r\n";
fwrite($fp, $out);
// while (!feof($fp)) {
// $receive .= fgets($fp, 128);
// }
fclose($fp);
}
public function sendSmsAll()
{
  var_dump($_POST);
  //发送短信的方法
}


//还可以使用curl实现

$ch = curl_init();

$curl_opt = array(CURLOPT_URL, ‘http://www.example.com/backend.php‘,

CURLOPT_RETURNTRANSFER, 1,

CURLOPT_TIMEOUT, 1,);

 

curl_setopt_array($ch, $curl_opt);

 

curl_exec($ch);

 

curl_close($ch);

 

PHP异步调用多线程

标签:

原文地址:http://www.cnblogs.com/godLike7/p/5606476.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!