thinkphp5ÅжÏÊÇ·ñÊÇpostÇëÇó
ÔÚʹÓÃthinkphp5¾ÙÐÐweb¿ª·¢Ê±£¬ÅжÏÄ¿½ñÇëÇóÊÇ·ñΪpostÇëÇóÊÇÒ»ÖÖ³£¼ûµÄÐèÇó¡£ÓÉÓÚpostÇëÇóÓëgetÇëÇó²î±ð£¬postÇëÇóͨ³£ÓÃÓÚÏòЧÀÍÆ÷Ìá½»Êý¾Ý£¬¶øgetÇëÇóͨ³£ÓÃÓÚ´ÓЧÀÍÆ÷»ñÈ¡Êý¾Ý¡£Òò´Ë£¬ÔÚÇø·ÖÇëÇóÀàÐÍʱ£¬»á¶Ô¶ÔÓ¦µÄÇëÇó×ö³ö²î±ðµÄ´¦Öóͷ£¡£
ÔÚThinkPHP5ÖУ¬ÅжÏÄ¿½ñµÄÇëÇóÊÇ·ñΪPOSTÇëÇóºÜÊǼòÆÓ¡£ÏÂÃæÏÈÈÝÈýÖÖÒªÁìÀ´ÅжÏÊÇ·ñΪPOSTÇëÇó¡£
ÒªÁìÒ»£ºÊ¹ÓÃrequest¹¤¾ß
ÔÚThinkPHP5ÖУ¬¿ÉÒÔͨ¹ýrequest¹¤¾ß»ñÈ¡Ä¿½ñÇëÇóµÄÏà¹ØÐÅÏ¢¡£Í¨¹ýÅжÏÄ¿½ñÇëÇóµÄ·½·¨ÊÇ·ñΪPOST£¬¼´¿ÉÅжÏÄ¿½ñÇëÇóÊÇ·ñΪPOSTÇëÇ󣬴úÂëÈçÏ£º
use thinkRequest; $request = Request::instance(); if ($request->isPost()) { // ´¦Öóͷ£POSTÇëÇóµÄÂß¼´úÂë }
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄ´úÂëÖУ¬Ê×ÏÈʵÀý»¯ÁËRequestÀ࣬²¢»ñÈ¡Ä¿½ñµÄÇëÇóÐÅÏ¢¡£½Ó×ÅŲÓÃRequest¹¤¾ßµÄisPost()ÒªÁìÀ´ÅжÏÄ¿½ñÇëÇóµÄ·½·¨ÊÇ·ñΪPOST¡£ÈôÊÇÊÇPOSTÇëÇó£¬ÔòÖ´ÐÐÏà¹ØµÄÓªÒµÂß¼¡£
ÒªÁì¶þ£ºÊ¹ÓÃinput¹¤¾ß
ÔÚThinkPHP5µÄ¿ØÖÆÆ÷ÖУ¬¿ÉÒÔͨ¹ýinput¹¤¾ß»ñÈ¡Ä¿½ñÇëÇóµÄÏà¹ØÐÅÏ¢¡£Í¨¹ýÅжÏÄ¿½ñÇëÇóµÄ·½·¨ÊÇ·ñΪPOST£¬¼´¿ÉÅжÏÄ¿½ñÇëÇóÊÇ·ñΪPOSTÇëÇ󣬴úÂëÈçÏ£º
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
use thinkController; class Index extends Controller { public function index() { $request = $this->request->param(); if ($this->request->isPost()) { // ´¦Öóͷ£POSTÇëÇóµÄÂß¼´úÂë } } }
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄ´úÂëÖУ¬input¹¤¾ßÒ²±»ÓÃÀ´»ñÈ¡Ä¿½ñÇëÇóµÄÐÅÏ¢¡£Í¨¹ýÇëÇ󹤾ߵÄisPost()ÒªÁ죬Ҳ¿ÉÒÔÅжÏÄ¿½ñÇëÇóÊÇPOSTÇëÇóÕÕ¾ÉÆäËûÀàÐ͵ÄÇëÇó¡£
ÒªÁìÈý£ºÊ¹ÓÃrequestÖúÊÖº¯Êý
ÔÚThinkPHP5ÖУ¬»¹ÌṩÁËÒ»ÖÖÔ½·¢ÇáÓ¯µÄÒªÁìÀ´ÅжÏÄ¿½ñÇëÇóÊÇ·ñΪPOSTÇëÇ󡣿ÉÒÔʹÓÃrequestÖúÊÖº¯Êý£¬´úÂëÈçÏ£º
if (request()->isPost()) { // ´¦Öóͷ£POSTÇëÇóµÄÂß¼´úÂë }
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÃæµÄ´úÂëÖУ¬Í¨¹ýŲÓÃrequest()ÒªÁì»ñÈ¡Ä¿½ñÇëÇóµÄÐÅÏ¢£¬²¢Ö±½ÓʹÓÃrequest()º¯ÊýµÄisPost()ÒªÁìÀ´ÅжÏÄ¿½ñÇëÇóÊÇ·ñΪPOSTÇëÇó¡£
ÎÞÂÛÊÇʹÓÃrequest¹¤¾ß¡¢input¹¤¾ßÕÕ¾ÉrequestÖúÊÖº¯Êý£¬¶¼¿ÉÒÔºÜÈÝÒ×µØÅжÏÄ¿½ñÇëÇóÊÇ·ñΪPOSTÇëÇó¡£ÔÚ¿ª·¢Àú³ÌÖУ¬¿ÉÒÔƾ֤ÏêϸÐèÇóÑ¡ÔñʹÓòî±ðµÄ·½·¨¡£
ÒÔÉϾÍÊÇthinkphp5ÅжÏÊÇ·ñÊÇpostÇëÇóµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡