1、PHP4以后獲取傳值的方法。
10年積累的網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有大理州免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
2、舊版本PHP3以前的獲取傳值方法。
3、修改PHP.ini文件的配置。
一、用file_get_contents函數(shù),以post方式獲取url
?php
$url=?'';
$data=?array('foo'=?'bar');
$data= http_build_query($data);
$opts=?array(
'http'=?array(
'method'=?'POST',
'header'="Content-type: application/x-www-form-urlencoded\r\n" ?.
"Content-Length: " ?.?strlen($data) .?"\r\n",
'content'=?$data
)
);
$ctx= stream_context_create($opts);
$html= @file_get_contents($url,'',$ctx);
二、用file_get_contents以get方式獲取內(nèi)容
?php
$url='';
$html=?file_get_contents($url);
echo$html;
?
三、用fopen打開url, 以get方式獲取內(nèi)容
?php
$fp=?fopen($url,'r');
$header= stream_get_meta_data($fp);//獲取報頭信息
while(!feof($fp)) {
$result.=?fgets($fp, 1024);
}
echo"url header: {$header} br":
echo"url body: $result";
fclose($fp);
?
四、用fopen打開url, 以post方式獲取內(nèi)容
?php
$data=?array('foo2'=?'bar2','foo3'='bar3');
$data= http_build_query($data);
$opts=?array(
'http'=?array(
'method'=?'POST',
'header'="Content-type: application/x-www-form-
urlencoded\r\nCookie:cook1=c3;cook2=c4\r\n" ?.
"Content-Length: " ?.?strlen($data) .?"\r\n",
'content'=?$data
)
);
$context= stream_context_create($opts);
$html=?fopen(';id2=i4','rb',false,?$context);
$w=fread($html,1024);
echo$w;
?
五、使用curl庫,使用curl庫之前,可能需要查看一下php.ini是否已經(jīng)打開了curl擴(kuò)展
?php
$ch= curl_init();
$timeout= 5;
curl_setopt ($ch, CURLOPT_URL,?'');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,?$timeout);
$file_contents= curl_exec($ch);
curl_close($ch);
echo$file_contents;
?
用戶在表格form
中填寫數(shù)據(jù),然后提交到一個php文件,PHP文件使用函數(shù)獲取數(shù)據(jù)
form action="welcome.php" method="post"
Name: input type="text" name="name"br
E-mail: input type="text" name="email"br
input type="submit" value="提交"
/form用戶填寫完username后提交到welcome.php文件,在welcome.php文件中,
html
body
Welcome ?php echo $_POST["name"]; ?br
Your email address is: ?php echo $_POST["email"]; ?
/body
/html$_POST["name"]就是用戶輸入的名字
本文題目:php取頁面數(shù)據(jù) html獲取php數(shù)據(jù)
轉(zhuǎn)載來源:http://chinadenli.net/article8/dodsgip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、移動網(wǎng)站建設(shè)、微信小程序、網(wǎng)站收錄、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)