thinkphpÔõÑùת´ïGET²ÎÊý
ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃURLµØµãÀ´×ª´ï²ÎÊý¡£ThinkPHP ¿ò¼Ü»á×Ô¶¯ÆÊÎö URL µØµãÖеIJÎÊý£¬²¢½«Æäת´ï¸øÏìÓ¦µÄ¿ØÖÆÆ÷ºÍÒªÁì¡£
ÀýÈ磬×ðÁú¿Ê± URL µØµãΪ£ºhttp://localhost/index.php/Index/index?id=1&name=thinkphp£¬ÆäÖÐ id=1 ºÍ name=thinkphp ¼´Îª×ª´ïµÄ²ÎÊý¡£ÔÚ¿ØÖÆÆ÷ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà $this->request->param() ÒªÁìÀ´»ñÈ¡ URL µØµãÖÐת´ïµÄ²ÎÊý¡£ÀýÈ磺
public function index() { $id = $this->request->param('id'); $name = $this->request->param('name'); echo 'ID=' . $id . ', Name=' . $name; }
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÕâÑù£¬µ±ÎÒÃÇ»á¼ûÉÏÊöµÄ URL µØµãʱ£¬¿ØÖÆÆ÷»áÊä³ö£ºID=1, Name=thinkphp¡£
³ýÁË URL µØµãת´ï²ÎÊýÍ⣬ÎÒÃÇÒ²¿ÉÒÔʹÓÃ±íµ¥À´×ª´ï²ÎÊý¡£ÔÚ HTML ±íµ¥ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓà name ÊôÐÔÀ´±êʶÐèҪת´ïµÄ²ÎÊý£¬¶øÔÚ¿ØÖÆÆ÷ÖÐͬÑù¿ÉÒÔʹÓà $this->request->param() ÒªÁìÀ´»ñÈ¡±íµ¥ÖÐת´ïµÄ²ÎÊý¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÀýÈ磬ÔÚ HTML ±íµ¥ÖУ¬ÎÒÃÇÐèҪת´ï id ºÍ name ²ÎÊý¡£Ôò¿ÉÒÔÕâÑù±àд 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() ÒªÁìÀ´»ñÈ¡±íµ¥ÖÐת´ïµÄ²ÎÊý¡£ÀýÈ磺
public function index() { $id = $this->request->param('id'); $name = $this->request->param('name'); echo 'ID=' . $id . ', Name=' . $name; }
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÕâÑù£¬µ±ÎÒÃÇÌá½»±íµ¥ºó£¬¿ØÖÆÆ÷ͬÑù»áÊä³ö£ºID=1, Name=thinkphp¡£
ÒÔÉϾÍÊÇthinkphpÔõÑùת´ïGET²ÎÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡