代碼如下:
石門ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
html?xmlns=""?
head?
meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312"?/?
titlephp獲取?checkbox復(fù)選框值的方法/title?
/head?
body?
form?name="form1"?method="post"?action=""?
label?
input?type="checkbox"?name="checkbox[]"?value="復(fù)選一"?
復(fù)選一?
/label?
label?
input?type="checkbox"?name="checkbox[]"?value="復(fù)選二"?
/label?
復(fù)選二?
label?
input?type="checkbox"?name="checkbox[]"?value="復(fù)選三"?
/label?
復(fù)選三?
label?
input?type="checkbox"?name="checkbox[]"?value="復(fù)選四"?
/label?
復(fù)選四?
label?
input?type="submit"?name="Submit"?value="提交"?
/label?
/form?
/body?
/html?
??
if(?$_POST?)?
{?
$value?=?$_POST['checkbox'];?
echo?'你選擇了:'.implode(',',$value);?
//由于checkbox屬性,我們必須把checkbox復(fù)選擇框的名字設(shè)置為一個如果checkbox[],這樣php才能讀取,以數(shù)據(jù)形式,否則不能正確的讀取checkbox復(fù)選框的值哦。//腳本之家?jb51.net?整理?
}?
?
一般是用post獲取提交的數(shù)據(jù),如下實(shí)例:
form?name="form1"?method="post"
p用戶名:input?type="text"?name="uname"?//p
p密碼:input?type="password"?name="upwd"?//p
pinput?type="submit"?name="btn"?value="提交"?//p
?php
if?($_POST["btn"]){
echo?'用戶名:'.$_POST["uname"].'br';//三體教程
echo?'密碼:'.$_POST["upwd"];
}
?
/form
方法1、最常見的方法是:$_post['fieldname'];
說明:只能接收content-type:
application/x-www-form-urlencoded提交的數(shù)據(jù)
解釋:也就是表單post過來的數(shù)據(jù)
方法2、file_get_contents("php://input");
說明:
允許讀取
post
的原始數(shù)據(jù)。
和
$http_raw_post_data
比起來,它給內(nèi)存帶來的壓力較小,并且不需要任何特殊的
php.ini
設(shè)置。
php://input
不能用于
enctype="multipart/form-data"。
解釋:
對于未指定
content-type
的post數(shù)據(jù),則可以使用file_get_contents(“php://input”);來獲取原始數(shù)據(jù)。
事實(shí)上,用php接收post的任何數(shù)據(jù)都可以使用本方法。而不用考慮content-type,包括二進(jìn)制文件流也可以。
所以用方法二是最保險的方法
方法3、$globals['http_raw_post_data'];
說明:
總是產(chǎn)生
$http_raw_post_data
變量包含有原始的
post
數(shù)據(jù)。
此變量僅在碰到未識別
mime
類型的數(shù)據(jù)時產(chǎn)生。
$http_raw_post_data
對于
enctype="multipart/form-data"
表單數(shù)據(jù)不可用
如果post過來的數(shù)據(jù)不是php能夠識別的,可以用
$globals['http_raw_post_data']來接收,
比如
text/xml
或者
soap
等等
解釋:
$globals['http_raw_post_data']存放的是post過來的原始數(shù)據(jù)。
$_post或$_request存放的是
php以key=value的形式格式化以后的數(shù)據(jù)。
但$globals['http_raw_post_data']中是否保存post過來的數(shù)據(jù)取決于centent-type的設(shè)置,即post數(shù)據(jù)時
必須顯式示指明content-type:
application/x-www-form-urlencoded,post的數(shù)據(jù)才會存放到
$globals['http_raw_post_data']中
在獲取表單數(shù)據(jù)中,最常用的自動全局變量是$_GET和$_POST,它們分別獲取通過GET方法提交的數(shù)據(jù)和通過POST方法提交的數(shù)據(jù)。
比如一個名稱為"user"的文本框表單控件,如果用GET方法提交,可以用 $_GET["user"]或者$_GET['user']
獲取它提交的值。
本文名稱:php獲取提交數(shù)據(jù) php獲取參數(shù)值的三種方式
分享鏈接:http://jinyejixie.com/article14/doschge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、網(wǎng)站內(nèi)鏈、服務(wù)器托管、響應(yīng)式網(wǎng)站、網(wǎng)站營銷、自適應(yīng)網(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)