>  기사  >  백엔드 개발  >  php实战第十四天_PHP教程

php实战第十四天_PHP教程

WBOY
WBOY원래의
2016-07-14 10:11:161279검색

今天学会了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); 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477369.htmlTechArticle今天学会了curl扩展的函数.写了一个 httpPost函数,恩是有效的,这个我想可以利用来做在线更新.或者是在线下载远程的资源. [php] echo httpPost(...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.