ThinkPHP? ?? PHP ?????? ?? ???? ?? PHP ?? ????????. ?? ??????? GET ???? ???? ????? ???? ?? ThinkPHP??? GET ???? ???? ????? ???? ?? ?? ?????.
?? ThinkPHP??? URL ??? ?? ????? ??? ? ????. URL ??? ????? ThinkPHP ?????? ?? ???? ?? ???? ?? ???? ? ???? ?????.
?? ?? URL ??? http://localhost/index.php/Index/index?id=1&name=thinkphp
???. ??? id=1
? name=thinkphp? ??? ???????. ?????? $this->request->param()
???? ???? URL ??? ??? ????? ??? ? ????. ?: http://localhost/index.php/Index/index?id=1&name=thinkphp
,其中 id=1
和 name=thinkphp
即為傳遞的參數(shù)。在控制器中,我們可以使用 $this->request->param()
方法來(lái)獲取 URL 地址中傳遞的參數(shù)。例如:
public?function?index() { ????$id?=?$this->request->param('id'); ????$name?=?$this->request->param('name'); ????echo?'ID='?.?$id?.?',?Name='?.?$name; }
這樣,當(dāng)我們?cè)L問(wèn)上述的 URL 地址時(shí),控制器會(huì)輸出:ID=1, Name=thinkphp
。
除了 URL 地址傳遞參數(shù)外,我們也可以使用表單來(lái)傳遞參數(shù)。在 HTML 表單中,我們可以使用 name
屬性來(lái)標(biāo)識(shí)需要傳遞的參數(shù),而在控制器中同樣可以使用 $this->request->param()
方法來(lái)獲取表單中傳遞的參數(shù)。
例如,在 HTML 表單中,我們需要傳遞 id
和 name
參數(shù)。則可以這樣編寫(xiě) HTML 代碼:
<form action="/index.php/Index/index" method="get"> ????<input type="text" name="id" value="1"> ????<input type="text" name="name" value="thinkphp"> ????<input type="submit" value="提交"> </form>
在控制器中,我們同樣可以使用 $this->request->param()
方法來(lái)獲取表單中傳遞的參數(shù)。例如:
public?function?index() { ????$id?=?$this->request->param('id'); ????$name?=?$this->request->param('name'); ????echo?'ID='?.?$id?.?',?Name='?.?$name; }
這樣,當(dāng)我們提交表單后,控制器同樣會(huì)輸出:ID=1, Name=thinkphp
。
綜上所述,ThinkPHP 中可以通過(guò) URL 地址或表單來(lái)傳遞 GET 參數(shù),而通過(guò) $this->request->param()
rrreee
ID=1, Name=thinkphp
? ?????. ????URL ??? ?? ????? ???? ? ??? ??? ???? ????? ??? ?? ????. HTML ????? name
??? ?????? ???? ?? ????? ??? ? ??, ??????? $this->request->param? ??? ?? ????. ()
??? ??? ????? ???? ??????. ?????? ?? HTML ????? id
? name
????? ???? ???. ?? ?? ??? ?? HTML ??? ??? ? ????. ??rrreee???????? $this->request->param()
???? ???? ??? ??? ????? ??? ?? ????. ?: ??rrreee???? ???? ??? ???? ????? ID=1, Name=thinkphp
? ?????. ???????? ThinkPHP??? URL ??? ?? ?? GET ????? ??? ? ??, $this->request->param()
???? ?? GET ????? ?? ?? ? ????. ??? ??? thinkphp?? GET ????? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)