Laravel 5:链接到 php 页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31673049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 : link to php page
提问by Gammer
I have two pages login.blade.php
and register.blade.php
. On my login.blade.php
i have link to register.blade.php
like this :
我有两页login.blade.php
和register.blade.php
. 在我的login.blade.php
我有这样的链接register.blade.php
:
<a href="register.php">Register a new membership</a>
When i click on the link to register.php it throws the following error :
当我点击 register.php 的链接时,它会引发以下错误:
NotFoundHttpException in RouteCollection.php line 143:
NotFoundHttpException in RouteCollection.php line 143:
Both login and register are in the same views folder.
login 和 register 都在同一个 views 文件夹中。
My route.php file have :
我的 route.php 文件有:
Route::get('/register', function(){
return view('register');
});
回答by davsp
Two things need to happen:
有两件事需要发生:
1) Remove the .php in your tag. It should be as such:
1) 删除标签中的 .php。它应该是这样的:
<a href="register">Register a new membership</a>
2) Make sure you are catching the 'register' route properly:
2) 确保您正确捕捉“注册”路线:
Route::get('register', function()
{
return view('register');
});
回答by Zahoor Ahmed
At first give a name to your route and then use it in then use it in anchar tag
首先为您的路线命名,然后在其中使用它,然后在 anchar 标签中使用它
Route::get('/', function () {
return view('welcome');
})->name('welcome');
Route::get('/about', 'PagesController@about')->name('about');
Now you can use it in any page to refer them. like in contact page
现在您可以在任何页面中使用它来引用它们。喜欢在联系页面
<html>
..
....
<a href="{{route('welcome')}}">Home</a>
<a href="{{route('about')}}">About</a>