OSC looked at someone asked how to tell whether the user is get or post, here to make a note
The HTTP header has a request Method that indicates whether the requests are get or post
Put a code on the YII code
Returns the method of the current request, keeping in mind that the method name is case sensitive and should be converted by specification to uppercase public function GetMethod () { //$this->methodparam default value ' _method ' If $_post[' _method ' is specified, the request is used to impersonate another method using a POST request. //$_post[' _method ' at this time is the type of request being simulated. if (isset ($_post[$this->methodparam])) { return strtoupper ($_post[$this->methodparam]); Or use the value of $_server[' Http_x_http_method_override '] as the method name. } elseif (Isset ($_server[' http_x_http_method_override ')) { return strtoupper ($_server[' http_x_http_ Method_override ']); or use $_server[' Request_method '] as the method name, not specified, default to GET method } else { return isset ($_server[' Request_method '])? C11/>strtoupper ($_server[' Request_method '): ' GET '; }}
This method uses 3 methods to obtain the current user's request, the priority from high to low is:
- When using a POST request to impersonate another request, use $_post[' _method '] As the method of the current request;
- Otherwise, if there is a x_http_method_override HTTP header, the method specified by the HTTP header is used as the request method, as X-http-method-override: put indicates that the request is to be executed by the Put method;
- If the x_http_method_override does not exist, the request_method Value as the method of the current request. If the even request_method does not exist, the request is considered a GET request.
The previous two methods were designed primarily for user agents that only support limited methods such as Get and post.
Determine whether a user source is a get or post based on the HTTP header