尊龙凯时人生就是博

laravelÌøתҳÃæ´«id

ÔÚlaravelÖУ¬ÌøתҳÃ沢ת´ï²ÎÊýÊǷǾ­³£¼ûµÄÐèÇó¡£ÆäÖУ¬°Ñid×÷Ϊ²ÎÊýת´ï¸øÏÂÒ»¸öÒ³ÃæÊÇÊ®·Ö³£¼ûµÄÐèÇó¡£±¾ÎĽ«½â˵ÔõÑùÔÚlaravelÖÐʵÏÖÌøתҳÃ沢ת´ïid²ÎÊýµÄÒªÁì¡£

µÚÒ»ÖÖÒªÁ죺ʹÓÃURL´«²Î

ʹÓÃURL´«²ÎÊÇ×î³£ÓõĴ«²ÎÒªÁìÖ®Ò»¡£Ëü¿ÉÒÔÈÃÎÒÃÇÔÚURLÖÐÌí¼ÓÐèҪת´ïµÄ²ÎÊý£¬È»ºóÔÚÏÂÒ»¸öÒ³ÃæÖÐͨ¹ý»ñÈ¡URL²ÎÊýÀ´Ê¹Óá£ÏÂÃæÊÇÏêϸʵÏÖ°ì·¨£º

Ê×ÏÈ£¬ÔÚ¿ØÖÆÆ÷ÖлñÈ¡²ÎÊý²¢Æ´½ÓURL£º

public function jump(Request $request)
{
    $id = $request->input('id');
    $url = '/detail?id=' . $id;
    return redirect($url);
}

µÇ¼ºó¸´ÖÆ

ÉÏÊö¿ØÖÆÆ÷ÒªÁìÖУ¬ÎÒÃÇͨ¹ý$request->input(‘id’)»ñȡת´ï¹ýÀ´µÄID£¬²¢½«ÆäÆ´½ÓÔÚURLÖС£È»ºóʹÓÃredirect($url)ÒªÁì¾ÙÐÐÌøת¡£ÏÂÃæÎÒÃÇÀ´¿´¿´ÔõÑùÔÚÏÂÒ»¸öÒ³ÃæÖлñÈ¡ID²ÎÊý¡£

public function detail(Request $request)
{
    $id = $request->input('id');
    // ...
}

µÇ¼ºó¸´ÖÆ

ÔÚÏÂÒ»¸ö´¦ÀíÒ³ÃæÖУ¬ÎÒÃÇͬÑùʹÓÃ$request->input(‘id’)ÒªÁì»ñÈ¡URLÖÐת´ï¹ýÀ´µÄID²ÎÊý£¬È»ºó¾Í¿ÉÒÔʹÓÃÕâ¸ö²ÎÊý¾ÙÐÐÏà¹ØµÄ²Ù×÷ÁË¡£

µÚ¶þÖÖÒªÁ죺ʹÓÃSession´«²Î

ÁíÒ»ÖÖ³£¼ûµÄ´«²ÎÒªÁìÊÇʹÓÃSession¡£ÕâÖÖÒªÁì¿ÉÒÔÔÚ²»Ì»Â¶²ÎÊýÐÅÏ¢µÄÇéÐÎÏÂת´ïÊý¾Ý¡£

Ê×ÏÈ£¬ÔÚ¿ØÖÆÆ÷Öн«²ÎÊý´æ´¢µ½SessionÖУº

public function jump(Request $request)
{
    $id = $request->input('id');
    $request->session()->put('id', $id);
    return redirect('/detail');
}

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖУ¬ÎÒÃÇͨ¹ý$request->session()->put(‘id’, $id)ÒªÁ콫ת´ï¹ýÀ´µÄID´æ´¢µ½SessionÖУ¬È»ºóʹÓÃredirect(‘/detail’)ÒªÁì¾ÙÐÐÌøת¡£

½ÓÏÂÀ´£¬ÔÚÏÂÒ»¸öÒ³ÃæÖÐͨ¹ýSession»ñÈ¡ID²ÎÊý£º

public function detail(Request $request)
{
    $id = $request->session()->get('id');
    // ...
}

µÇ¼ºó¸´ÖÆ

ÔÚÏÂÒ»¸ö´¦ÀíÒ³ÃæÖУ¬ÎÒÃÇͬÑùʹÓÃ$request->session()->get(‘id’)ÒªÁì»ñÈ¡SessionÖд洢µÄID²ÎÊý£¬È»ºó¾Í¿ÉÒÔʹÓÃÕâ¸ö²ÎÊý¾ÙÐÐÏà¹ØµÄ²Ù×÷ÁË¡£

×ܽá

ÒÔÉϾÍÊÇÁ½ÖÖ³£ÓõÄÔÚLaravelÖÐÌøתҳÃ沢ת´ïID²ÎÊýµÄÒªÁì¡£ÎÞÂÛÊÇʹÓÃURL´«²ÎÕÕ¾ÉʹÓÃSession´«²Î£¬¶¼¿ÉÒÔ¿ìËÙ¼òÆÓµØʵÏÖÕâÒ»ÐèÇó¡£ÔÚʹÓÃÕâЩҪÁìµÄʱ¼ä£¬ÎñÐëҪעÖزÎÊýµÄÇå¾²ÐÔ£¬×èÖ¹·ºÆð²ÎÊý±»¶ñÒâ¸Ä¶¯µÄÇéÐΡ£

ÒÔÉϾÍÊÇlaravelÌøתҳÃæ´«idµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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