thinkphpÔõôת´ï²ÎÊý
thinkphpÊÇÒ»¸ö»ùÓÚmvc¼Ü¹¹µÄphp¿ªÔ´¿ò¼Ü£¬Æäת´ï²ÎÊýµÄ·½·¨ÓÐÐí¶àÖÖ¡£ÏÂÃæ¾ÍÀ´ÏÈÈݼ¸ÖÖ³£Óõķ½·¨¡£
GET·½·¨´«²ÎÊý
ÔÚÒ³ÃæµØµãÀ¸ÖÐת´ïµÄ²ÎÊý£¬Í¨¹ý$_GETÈ«¾Ö±äÁ¿»ñÈ¡¡£
ÀýÈ磺http://localhost/index.php/Home/Index/index?id=1
ÔÚ¿ØÖÆÆ÷ÖпÉÒÔÕâÑù»ñÈ¡£º$id = $_GET[‘id’];
POST·½·¨´«²ÎÊý
ÔÚ±íµ¥Ìá½»Àú³ÌÖУ¬Í¨¹ý$_POSTÈ«¾Ö±äÁ¿»ñÈ¡Êý¾Ý¡£
ÀýÈ磺±íµ¥ÖÐÓиöinputÊäÈë¿òµÄnameÊôÐÔΪage£¬ÔÚ¿ØÖÆÆ÷ÖпÉÒÔÕâÑù»ñÈ¡£º$age = $_POST[‘age’];
URLµØµãת´ï²ÎÊý
ÀýÈ磺ÔÚ¿ØÖÆÆ÷ÖÐÌìÉú·ÓÉ£º
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
$url = url(‘index/details’, [‘id’ => 1]);
ÔÚ·ÓÉÖлá¼û£º
public function details($id)
{
echo $id;
µÇ¼ºó¸´ÖÆ
}
SESSION·½·¨×ª´ï²ÎÊý
ÀýÈ磺ÔÚij¸öÒ³ÃæÖи³Öµ£ºsession(‘username’, ‘tom’);
ÔÚ¿ØÖÆÆ÷ÖпÉÒÔÕâÑù»ñÈ¡£º$username = session(‘username’);
COOKIES·½·¨×ª´ï²ÎÊý
ÀýÈ磺ÔÚij¸öÒ³ÃæÖи³Öµ£ºcookie(‘username’, ‘tom’, 3600);
ÔÚ¿ØÖÆÆ÷ÖпÉÒÔÕâÑù»ñÈ¡£º$username = cookie(‘username’);
REQUEST·½·¨×ª´ï²ÎÊý
ÕâÊÇÒ»ÖÖ½ÏÁ¿ÎÞаµÄ·½·¨£¬Ëüͬʱ֧³ÖGETºÍPOST·½·¨¡£
ÀýÈ磺$id = request()->param(‘id’);
×ܽá
ÕâЩ¶¼ÊǽÏÁ¿³£¼ûµÄ´«²Î·½·¨£¬ÉÁ¿ª·¢ÕßÔÚÏîÄ¿ÖÐÔ½·¢ÎÞаÀû±ãµÄʹÓá£ÔÚÏîÄ¿¿ª·¢ÖУ¬ÎÒÃÇÐèҪƾ֤ÏÖÕæÏàÐÎÎÞаѡÔñºÏÊʵķ½·¨×ª´ï²ÎÊý¡£
ÒÔÉϾÍÊÇthinkphpÔõôת´ï²ÎÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡