Home > Backend Development > PHP Tutorial > Laravel的路由带参数写法

Laravel的路由带参数写法

WBOY
Release: 2016-06-06 20:43:39
Original
1776 people have browsed it

<code>Route::get('login', '控制器类名称@方法');
</code>
Copy after login
Copy after login

正常路由中访问控制器方法的格式是这样的

现在我在控制器中的方法写成了这样:

<code>public function redirectTo($states, $callback){
    # code...
}
</code>
Copy after login
Copy after login

在路由器中访问这个方法,改怎么写?要带上$states和$callback参数。

回复内容:

<code>Route::get('login', '控制器类名称@方法');
</code>
Copy after login
Copy after login

正常路由中访问控制器方法的格式是这样的

现在我在控制器中的方法写成了这样:

<code>public function redirectTo($states, $callback){
    # code...
}
</code>
Copy after login
Copy after login

在路由器中访问这个方法,改怎么写?要带上$states和$callback参数。

<code>Route::get('user/{states}/{callback}', '控制器类名称@方法');
</code>
Copy after login

也可以看看这里
https://github.com/5-say/laravel-4.1-simple-blog/blob/master/app/routes.php

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template