Verification method: 1. Use the "dd(request()->method(), $_SERVER['REQUEST_METHOD'])" statement; 2. Use the isMethod method of the Request object, the syntax "$request- >isMethod('Request Type')".
The operating environment of this tutorial: Windows 7 system, Laravel 6 version, Dell G3 computer.
In Laravel, sometimes we need to distinguish request types to return different results, so how to verify the request method? Two methods are introduced below.
Method 1:
1 |
|
Method 2: Judge through the isMethod method of the Request object
1 2 3 4 5 6 7 |
|
Related recommendations: The latest five Laravel video tutorials
The above is the detailed content of How to verify request method in laravel. For more information, please follow other related articles on the PHP Chinese website!