尊龙凯时人生就是搏

laravel²î±ðurl²î±ð¿ØÖÆÆ÷

×÷Ϊһ¿îÊ¢ÐеÄphp¿ò¼Ü£¬laravel±»ÆÕ±éµØÓ¦ÓÃÓÚwebÓ¦ÓóÌÐòµÄ¿ª·¢¡£laravelÌṩÁËһϵÁеÄÇ¿Ê¢¹¦Ð§£¬ÆäÖаüÀ¨Ê¹Óòî±ðµÄurl»á¼û²î±ð¿ØÖÆÆ÷µÄ¹¦Ð§¡£Õâ¸ö¹¦Ð§¹ØÓÚ´óÐÍwebÓ¦ÓóÌÐòºÜÊÇÓÐÓã¬ÓÉÓÚËüÄܹ»Ê¹Ó¦ÓóÌÐòÔ½·¢ÎÞаºÍÒ×ÓÚά»¤¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ½«ÏêϸÏÈÈÝlaravelÔõÑùʵÏÖ²î±ðµÄurl»á¼û²î±ðµÄ¿ØÖÆÆ÷¡£

ÔÚLaravelÖУ¬Ã¿¸öURL¶¼ÓÉ·ÓÉ´¦Àí¡£Â·ÓÉÊǽ«URLÓë¿ØÖÆÆ÷»òÐж¯ÒªÁì¾ÙÐÐÓ³ÉäµÄ»úÖÆ¡£ÎªÁËʵÏÖ²î±ðURL»á¼û²î±ð¿ØÖÆÆ÷µÄ¹¦Ð§£¬ÎÒÃÇÐèÒªÔÚ·ÓÉÖÐÉèÖöà¸öURL£¬Ê¹ËüÃÇ»®·ÖÖ¸Ïò²î±ðµÄ¿ØÖÆÆ÷¡£

ÔÚLaravelÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃRoute::get()º¯ÊýÀ´½ç˵·ÓÉ¡£ÏÂÃæÊÇËüµÄ»ù±¾Óï·¨£º

Route::get('/url', 'Controller@method');

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÓï·¨ÖУ¬ÎÒÃÇÐèÒªÖ¸¶¨URLºÍ¿ØÖÆÆ÷µÄÒªÁì¡£URLÊÇWebÓ¦ÓóÌÐòÖеÄÖ÷»úÃûºóÃæµÄ·¾¶¡£Õâ¸ö·¾¶¿ÉÒÔÊǼòÆÓµÄ×Ö·û´®£¬ÀýÈç’/hello’£¬Ò²¿ÉÒÔ°üÀ¨²ÎÊý£¬ÀýÈç’/user/{id}’¡£¿ØÖÆÆ÷ÒªÁìÖ¸¶¨ÁË´¦ÀíÇëÇóµÄÂß¼­´úÂë¡£

ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔ½¨ÉèÐí¶à·ÓÉ£¬²¢½«ËüÃÇ·ÖÅɸø²î±ðµÄ¿ØÖÆÆ÷¡£ÏÂÃæÊÇÒ»¸öʵÀý£¬ÆäÖÐÎÒÃǽç˵ÁËÁ½¸öURL£º’/home’ºÍ’/about’£¬²¢½«ËüÃÇ»®·Ö·ÖÅɸøÁ½¸ö²î±ðµÄ¿ØÖÆÆ÷¡£

//½ç˵·ÓÉ
Route::get('/home', 'HomeController@index');
Route::get('/about', 'AboutController@index');

//½ç˵HomeController
class HomeController extends Controller
{
    public function index()
    {
        return view('home');
    }
}

//½ç˵AboutController
class AboutController extends Controller
{
    public function index()
    {
        return view('about');
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃǽç˵ÁËÁ½¸ö·ÓÉ£º’/home’ºÍ’/about’¡£ÕâÁ½¸ö·ÓÉ»®·ÖÖ¸Ïò²î±ðµÄ¿ØÖÆÆ÷HomeControllerºÍAboutController¡£Ã¿¸ö¿ØÖÆÆ÷¶¼ÓÐÒ»¸öÃûΪ’index’µÄÒªÁ죬Ëü´¦Àí¶ÔÓ¦µÄÇëÇó¡£ÔÚÕâ¸öÀý×ÓÖУ¬’index’ÒªÁì·µ»Ø²î±ðµÄÊÓͼ£¬»®·ÖΪ’home’ºÍ’about’¡£

ҪעÖصÄÊÇ£¬ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÎÒÃÇʹÓÃÁËLaravelµÄĬÈÏÊÓͼÎļþ´æ·ÅλÖ㬼´resources/viewsÎļþ¼Ð¡£ÔÚÕâ¸öÎļþ¼ÐÖУ¬ÎÒÃǽ¨ÉèÁËÁ½¸öÊÓͼÎļþ£ºhome.blade.phpºÍabout.blade.php¡£ÕâÁ½¸öÎļþ½«±»·µ»Ø¸ø¿Í»§¶Ë¡£

ÔÚÏÖʵӦÓóÌÐòÖУ¬ÎÒÃÇ¿ÉÄÜÐèÒªÔ½·¢ÖØ´óµÄ·ÓɺͿØÖÆÆ÷¡£ÀýÈ磬ÎÒÃÇ¿ÉÄÜÐèÒªÔÚURLÖаüÀ¨²ÎÊý£¬Ê¹ÓÿØÖÆÆ÷ÖеÄÄ£×ÓÀ´¼ìË÷Êý¾Ý£¬²¢½«Êý¾Ýת´ï¸øÊÓͼÎļþ¡£ÏÂÃæÊÇÒ»¸ö¸üÏÖʵµÄÀý×Ó£º

Route::get('/article/{id}', 'ArticleController@show');

class ArticleController extends Controller
{
    public function show($id)
    {
        $article = Article::find($id);
        return view('article.show', ['article' => $article]);
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃǽç˵ÁËÒ»¸ö´øÓвÎÊýµÄURL£º’/article/{id}’¡£Õâ¸ö²ÎÊýÓÃÓÚÖ¸¶¨ÐèÒªÏÔʾµÄÎÄÕ¡£ÎÒÃÇʹÓÃÒ»¸öÃûΪ’show’µÄÒªÁìÀ´´¦ÀíÕâ¸öÇëÇó¡£ÔÚÕâ¸öÒªÁìÖУ¬ÎÒÃÇʹÓÃArticleÄ£×Ó´ÓÊý¾Ý¿âÖмìË÷ÎÄÕ¡£È»ºó£¬ÎÒÃǽ«Õâ¸öÎÄÕÂת´ï¸øÃûΪ’article.show’µÄÊÓͼ¡£

×ܽáÆðÀ´£¬Laravel¿ÉÒÔ×ÊÖúÎÒÃÇʵÏÖ²î±ðµÄURL»á¼û²î±ð¿ØÖÆÆ÷µÄ¹¦Ð§¡£ÎÒÃÇ¿ÉÒÔÔÚ·ÓÉÖÐÉèÖöà¸öURL£¬²¢½«ËüÃÇ»®·ÖÖ¸Ïò²î±ðµÄ¿ØÖÆÆ÷¡£ÔÚ¿ØÖÆÆ÷ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÊʵ±µÄÂß¼­´úÂë´¦Àí¶ÔÓ¦µÄÇëÇó²¢·µ»ØÏìÓ¦µÄÊÓͼÎļþ¡£Õâ¸ö¹¦Ð§¹ØÓÚ´óÐÍÓ¦ÓóÌÐòµÄ¿ª·¢ºÜÊÇÓÐÓã¬ÓÉÓÚËüʹÎÒÃǵĴúÂëÔ½·¢ÎÞаºÍÒ×ÓÚά»¤¡£

ÒÔÉϾÍÊÇlaravel²î±ðurl²î±ð¿ØÖÆÆ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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