Home > Backend Development > PHP Tutorial > How to obtain various paths in laravel

How to obtain various paths in laravel

WBOY
Release: 2016-07-29 08:52:49
Original
1643 people have browsed it

If there is Route::get('home/test', 'HomeController@index')->name('test');

①href jump in the view

1.

Difference: The most convenient, but it will need to be modified when the route changes

2. >name()

3.

Difference: Directly specify the relevant controller, minimal impact

Four.

Difference: most easily affected, not recommended to use

② Use redirect jump in the controller

1. return redirect(' home/test'); <=> return redirect()->to('home/test');

Difference: Same as ① 1

2. return redirect()->action ('HomeController@index');

Difference: Same as ①Three

Three, return redirect()->route(test'');

Difference: Same as ①Two

4. return redirect()->back(); <=> return back();

Instructions: Return to the previous page

③Each resource path constant

1. public_path( 'uploads');

Explanation: public file path

2. base_path('xx');

3. app_path('xx');

4. resource_path('xx ');

The above introduces how to obtain various paths in laravel, including laravel content. I hope it will be helpful to friends who are interested in PHP tutorials.

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