今天學會了curl擴展的函數.寫了一個 httpPost函數,恩是有效的,這個我想可以利用來做在線更新.或者是在線下載遠程的資源.
[php]
echo httpPost("http://bbs.125.la/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1",
array (
"handlekey" => "ls",
"password" => "123456",
"quickforward" => "yes",
"username" => "admin"
));
function httpPost($url,$sendData)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 我們在POST數據哦!
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的變量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $sendData);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
echo httpPost("http://bbs.125.la/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1",
array (
"handlekey" => "ls",
"password" => "123456",
"quickforward" => "yes",
"username" => "admin"
));
function httpPost($url,$sendData)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 我們在POST數據哦!
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的變量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $sendData);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
以下是標准的mysql查詢數據並組合成數組的代碼
[php]
$conn=mysql_connect('localhost','root','1234');
mysql_select_db('kefei');
mysql_query("set names utf8");
$result=mysql_query("select * from liuyan");
$arr=array();
while($row=mysql_fetch_assoc($result)){
$arr[]=$row
}
var_dump($arr);