isMethod('post') ){code to be executed}"."/> isMethod('post') ){code to be executed}".">
Home >PHP Framework >Laravel >How does laravel determine whether it is post transmission?
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}".
The operating environment of this article: Windows 10 system, Laravel version 5.4, Dell G3 computer.
You can use post transmission to determine whether the form form has a value. Post it:
if($request->isMethod('post')){ // 要执行的代码 }
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执行的代码 } }
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();
Get xml, json
// 原生php写法 $content = file_get_contents("php://input"); // laravel框架写法 $content = $request->getcontent();
[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!