isMethod('post') ){code to be executed}"."> How does laravel determine whether it is post transmission?-Laravel-php.cn
Home> PHP Framework> Laravel> body text

How does laravel determine whether it is post transmission?

WBOY
Release: 2022-06-02 17:22:54
Original
2538 people have browsed it

In laravel, you can use the isMethod method of the Request object with the if statement to determine whether it is a post transmission request. Just set the parameter to "post", and the syntax is "if($request-> ;isMethod('post')){code to be executed}".

How does laravel determine whether it is post transmission?

The operating environment of this article: Windows 10 system, Laravel version 5.4, Dell G3 computer.

How does laravel determine whether it is post transmission?

You can use post transmission to determine whether the form form has a value. Post it:

if($request->isMethod('post')){ // 要执行的代码 }
Copy after login

It is done through the isMethod method of the Request object. judge!

Examples are as follows:

Judge whether it is a get or post request

public function interview_add(Request $request,int $id){ if($request->isMethod('get')){ //get执行的代码 }elseif ($request->isMethod('post')){ //post执行的代码 } }
Copy after login

Extended knowledge:

PHP, laravel acquisition Post requested params, xml, json

Get all params

//php原生写法 $content = $_POST; //或者 $content = file_get_contents(“php://input”); //laravel写法 $content = $request->all();
Copy after login

Get xml, json

// 原生php写法 $content = file_get_contents("php://input"); // laravel框架写法 $content = $request->getcontent();
Copy after login

[Related recommendations:laravel video tutorial]

The above is the detailed content of How does laravel determine whether it is post transmission?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!