×ðÁú¿­Ê±

laravel Ä£°æÄÚÀïÔõô»ñÈ¡Ä¿½ñÒªÁì

ÔÚ laravel ÖÐ £¬»ñÈ¡Ä¿½ñÒªÁì¿ÉÒÔʹÓà illuminatehttprequest ÀàµÄ method() ÒªÁì ¡£¸ÃÒªÁ콫·µ»ØÄ¿½ñÇëÇóµÄ http ÒªÁì ¡£

ÔÚ Laravel µÄ Blade Ä£°åÖÐ £¬¿ÉÒÔʹÓà {{ request()->method() }} »ñÈ¡Ä¿½ñÇëÇóµÄÒªÁì ¡£ÀýÈ磺

@if (request()->method() == 'POST')
    ÇëÇó·½·¨Îª POST
@elseif (request()->method() == 'GET')
    ÇëÇó·½·¨Îª GET
@else
    ÇëÇó·½·¨ÎªÆäËü
@endif

µÇ¼ºó¸´ÖÆ

ÔÚ¿ØÖÆÆ÷ÖÐ £¬¿ÉÒÔʹÓà $request->method() »ò $request->getMethod() »ñÈ¡Ä¿½ñÇëÇóµÄÒªÁì ¡£ÀýÈ磺

public function index(Request $request)
{
    if ($request->method() == 'POST') {
        // ´¦Öóͷ£ POST ÇëÇó
    }

    if ($request->getMethod() == 'GET') {
        // ´¦Öóͷ£ GET ÇëÇó
    }
}

µÇ¼ºó¸´ÖÆ

ÁíÍâ £¬ÔÚ¿ØÖÆÆ÷ÖÐ £¬Ò²¿ÉÒÔʹÓà PHP ÄÚÖÃµÄ $_SERVER[‘REQUEST_METHOD’] ±äÁ¿»ñÈ¡Ä¿½ñÇëÇóµÄÒªÁì ¡£ÀýÈ磺

public function index()
{
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        // ´¦Öóͷ£ POST ÇëÇó
    }

    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
        // ´¦Öóͷ£ GET ÇëÇó
    }
}

µÇ¼ºó¸´ÖÆ

ÐèҪעÖصÄÊÇ £¬Ê¹Óà $_SERVER[‘REQUEST_METHOD’] ±äÁ¿µÄ·½·¨²»ÈçʹÓà Laravel ÌṩµÄ Request ÀàµÄ·½·¨ÓÅÑźÍÀû±ã ¡£

ÒÔÉϾÍÊÇlaravel Ä£°æÄÚÀïÔõô»ñÈ¡Ä¿½ñÒªÁìµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼ ¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý ¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿