while轮回中不支撑轮回应用curl
添加时间:2013-7-29 点击量:
<?php
¥link = mysql_connect(localhost, sms, sms);
mysql__db(sms, ¥link);
mysql_query(set names utf8);
¥sql =
SELECT phone,chang, msg, linkid, mo_time FROM tables ;
¥result = mysql_query(¥sql,¥link);
¥array = array();
while(¥row = mysql_fetch_array(¥result)){
¥linkid = ¥row[phone].date(YmdHis, strtotime(¥row[mo_time]));
¥str = SPNUM=.¥row[chang].&MOBILE=.¥row[phone].&CONTENT=.urlencode(¥row[msg]).&MOTIME=.urlencode(¥row[mo_time]).&LINKID=.¥linkid;
¥url = www.baidu.com?.¥str;
¥array[] = ¥url;
//var_dump(¥url); 这里应用curl接见,只能接见一条随后就中断了,只能在上方存放到数组中
/¥result = file_get_contents(¥url);
var_dump(¥result);/
/¥ch = curl_init(¥url);
curl_setopt(¥ch, CURLOPT_TIMEOUT, 40);
curl_setopt(¥ch, CURLOPT_RETURNTRANSFER, true);
¥result = curl_exec(¥ch);
// 4. 开释curl句柄
curl_close(¥ch);/
}
//var_dump(¥array);
//这里应用foreach轮回履行curl号令
foreach (¥array as ¥url) {
var_dump(¥url);
¥ch = curl_init(¥url);
curl_setopt(¥ch, CURLOPT_TIMEOUT, 40);
curl_setopt(¥ch, CURLOPT_RETURNTRANSFER, true);
¥result = curl_exec(¥ch);
// 4. 开释curl句柄
curl_close(¥ch);
var_dump(¥result);
}
<?php
¥link = mysql_connect(localhost, sms, sms);
mysql__db(sms, ¥link);
mysql_query(set names utf8);
¥sql =
SELECT phone,chang, msg, linkid, mo_time FROM tables ;
¥result = mysql_query(¥sql,¥link);
¥array = array();
while(¥row = mysql_fetch_array(¥result)){
¥linkid = ¥row[phone].date(YmdHis, strtotime(¥row[mo_time]));
¥str = SPNUM=.¥row[chang].&MOBILE=.¥row[phone].&CONTENT=.urlencode(¥row[msg]).&MOTIME=.urlencode(¥row[mo_time]).&LINKID=.¥linkid;
¥url = www.baidu.com?.¥str;
¥array[] = ¥url;
//var_dump(¥url); 这里应用curl接见,只能接见一条随后就中断了,只能在上方存放到数组中
/¥result = file_get_contents(¥url);
var_dump(¥result);/
/¥ch = curl_init(¥url);
curl_setopt(¥ch, CURLOPT_TIMEOUT, 40);
curl_setopt(¥ch, CURLOPT_RETURNTRANSFER, true);
¥result = curl_exec(¥ch);
// 4. 开释curl句柄
curl_close(¥ch);/
}
//var_dump(¥array);
//这里应用foreach轮回履行curl号令
foreach (¥array as ¥url) {
var_dump(¥url);
¥ch = curl_init(¥url);
curl_setopt(¥ch, CURLOPT_TIMEOUT, 40);
curl_setopt(¥ch, CURLOPT_RETURNTRANSFER, true);
¥result = curl_exec(¥ch);
// 4. 开释curl句柄
curl_close(¥ch);
var_dump(¥result);
}