尊龙凯时人生就是搏

laravel ÐÞ¸ÄÇëÇó²ÎÊý

laravelÊÇÒ»¸ö»ùÓÚphpµÄ¿ªÔ´webÓ¦ÓóÌÐò¿ò¼Ü £¬ËüÌṩÁËһЩºÜÊÇÓÐÓõĹ¦Ð§ £¬ÀýÈç·ÓÉ £¬ÖÐÐļþ £¬Ä£°åÒýÇæµÈ¡£ÔÚ¿ª·¢Àú³ÌÖÐ £¬ÎÒÃǾ­³£ÐèÒª´¦ÀíÇëÇó²ÎÊý¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚlaravelÖÐÐÞ¸ÄÇëÇó²ÎÊý¡£

»ñÈ¡ÇëÇó²ÎÊý

ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓÃÒÔÏ´úÂëÀ´»ñÈ¡ÇëÇó²ÎÊý£º

$request->input('parameter_name');

µÇ¼ºó¸´ÖÆ

Õ⽫·µ»ØÇëÇó²ÎÊýµÄÖµ¡£ÈôÊÇÇëÇóûÓÐÌṩ¸Ã²ÎÊý £¬Ëü½«·µ»Ønull¡£ÀýÈç £¬ÒÔÏ´úÂ뽫»ñÈ¡ÃûΪ¡°id¡±µÄÇëÇó²ÎÊýµÄÖµ£º

$id = $request->input('id');

µÇ¼ºó¸´ÖÆ

ÐÞ¸ÄÇëÇó²ÎÊý

ÓÐʱ¼ä £¬ÎÒÃÇÐèÒªÐÞ¸ÄÇëÇó²ÎÊýµÄÖµ¡£ÀýÈç £¬µ±ÎÒÃÇÎüÊÕµ½Ò»¸öÇëÇóʱ £¬ÎÒÃÇÏë¸ü¸ÄһЩ²ÎÊýµÄÖµÀ´¾ÙÐÐÑéÖ¤»ò´¦Àí¡£ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓÃÒÔÏÂÒªÁìÀ´ÐÞ¸ÄÇëÇó²ÎÊý£º

$request->merge(['parameter_name' => 'new_value']);

µÇ¼ºó¸´ÖÆ

Õ⽫Óá°new_value¡±Ìæ»»ÇëÇó²ÎÊý¡°parameter_name¡±µÄÄ¿½ñÖµ¡£ÀýÈç £¬ÒÔÏ´úÂ뽫°ÑÃûΪ¡°id¡±µÄÇëÇó²ÎÊýµÄÖµ¸ü¸ÄΪ¡°new_id¡±£º

$request->merge(['id' => 'new_id']);

µÇ¼ºó¸´ÖÆ

Öض¨Ïò

ÓÐʱ¼ä £¬ÎÒÃÇÐèÒªÔÚ´¦ÀíÇëÇó֮ǰ½«ÇëÇóÖض¨Ïòµ½ÁíÒ»¸öURL¡£ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓÃÒÔÏÂÒªÁìÖض¨ÏòÇëÇó£º

return redirect()->to('new_url');

µÇ¼ºó¸´ÖÆ

Õ⽫Öض¨ÏòÇëÇ󵽡°new_url¡±¡£µ±ÔÚ¿ØÖÆÆ÷ÖÐʹÓôËÒªÁìʱ £¬¿ÉÒÔÖ´ÐÐÆäËû²Ù×÷ £¬ÀýÈ磺

public function index(Request $request)
{
    if ($request->input('id') == null) {
        $request->merge(['id' => 'default_id']);
        return redirect()->back();
    }
    // ...
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖÐ £¬ÈôÊÇÇëÇóûÓÐÌṩ¡°id¡±µÄÖµ £¬¿ØÖÆÆ÷½«Í¨¹ý½«Æä¸ü¸ÄΪ¡°default_id¡±À´ÐÞ¸ÄÇëÇó²ÎÊý¡£È»ºó £¬¿ØÖÆÆ÷½«Ê¹ÓÃredirect()->back()½«Óû§Öض¨Ïò»Ø֮ǰµÄÒ³Ãæ¡£

ÖØдÇëÇóÒªÁì

ÓÐʱ¼ä £¬ÎÒÃÇÐèÒª¸ü¸ÄÇëÇóÒªÁì¡£ÀýÈç £¬ÎÒÃÇÏ£Íûͨ¹ýPOSTÇëÇó·¢ËÍÊý¾Ý £¬¿ÉÊÇÎÒÃÇÖ»ÓÐGETÇëÇó¡£ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ뽫HTTPÇëÇóÒªÁì¸ü¸ÄΪPOST£º

$request->setMethod('POST');

µÇ¼ºó¸´ÖÆ

Õ⽫ǿÖÆÇëÇóʹÓÃPOSTÒªÁì¡£ÀýÈç £¬ÒÔÏ´úÂ뽫ÔÚGETÇëÇóÖиü¸ÄÇëÇóÒªÁ죺

public function index(Request $request)
{
    if ($request->isMethod('GET')) {
        $request->setMethod('POST');
        $request->merge(['id' => 'new_id']);
        return redirect()->back();
    }
    // ...
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖÐ £¬¿ØÖÆÆ÷½«¼ì²éÇëÇóÊÇ·ñΪGET¡£ÈôÊÇÊÇ £¬Ôò½«Æä¸ü¸ÄΪPOST £¬²¢½«¡°id¡±²ÎÊý¸ü¸ÄΪ¡°new_id¡±¡£È»ºó £¬¿ØÖÆÆ÷½«Ê¹ÓÃredirect()->back()½«Óû§Öض¨Ïò»Ø֮ǰµÄÒ³Ãæ¡£

×ܽá

ÔÚLaravelÖÐ £¬ÐÞ¸ÄÇëÇó²ÎÊýºÜÈÝÒס£ÒªÁì°üÀ¨»ñÈ¡ÇëÇó²ÎÊý £¬ÐÞ¸ÄÇëÇó²ÎÊý £¬Öض¨ÏòÇëÇóºÍÖØдÇëÇóÒªÁì¡£ÎÞÂÛÄúÊÇÔÚ±àд¿ØÖÆÆ÷ÕÕ¾ÉʹÓÃÖÐÐļþ £¬ÕâЩҪÁ춼¿ÉÒÔ×ÊÖúÄú´¦ÀíÇëÇó¡£

ÒÔÉϾÍÊÇlaravel ÐÞ¸ÄÇëÇó²ÎÊýµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

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