Home  >  Article  >  PHP Framework  >  Introduction to commonly used auxiliary functions in the Laravel framework

Introduction to commonly used auxiliary functions in the Laravel framework

不言
不言Original
2018-07-31 16:47:472836browse

Laravel framework There are many very useful auxiliary functions. In the following article, I will introduce you to several commonly used auxiliary functions.

1.csrf token form

{{ csrf_token() }}

In this way, you can directly obtain the csrf_token maintained by Laravel itself. For example, it is usually used like this:

<input name="_token" value="{{ csrf_token() }}" type="hidden" />

Or you can also directly get the hidden form of csrf token like this:

{!! csrf_field() !!}

This will directly output content similar to the following in html:

<input name="_token" value="3E0fFDOHQylQFdM1UQ8pjJyMuN8YP5erC6VxoHY8" type="hidden" />

2. Generate method form

When using resource routing, there are some methods that the browser cannot support natively, such as DELETE, PATCH PUT, etc. At this time, you can use the code To generate method forms and simulate these requests:

 {{ method_field('DELETE') }}

Generated HTML:

<input type="hidden" name="_method" value="DELETE">

The above is the entire content of this article. For more laravel content, please pay attention to the laravel framework introductory tutorial. .

Recommended related articles:

The process of using Echo in the Laravel framework

The implementation of laravel framework in data statistical drawing

Related course recommendations:

The latest five Laravel video tutorial recommendations in 2017

The above is the detailed content of Introduction to commonly used auxiliary functions in the Laravel framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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