Home  >  Article  >  Backend Development  >  The fourteenth day of PHP practice_PHP tutorial

The fourteenth day of PHP practice_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:11:161323browse

I learned the curl extension function today. I wrote an httpPost function, and it is effective. I think this can be used for online updates or to download remote resources online.

[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);
// We are POSTing data!
curl_setopt($ch, CURLOPT_POST, 1);
// Add the post variable to
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);
// We are POSTing data!
curl_setopt($ch, CURLOPT_POST, 1);
//Add
to the post variable curl_setopt($ch, CURLOPT_POSTFIELDS, $sendData);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}

The following is the code for standard mysql query data and combining it into an array
[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);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477369.htmlTechArticleToday I learned the function of curl extension. I wrote an httpPost function, and it is effective. I think I can use this To do online updates or download remote resources online. [php] echo httpPost(...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn