Get:
Yii::$app->request->get($key, $default)
The first parameter ($key) is the key requested by the user get, and the first parameter is optional; The two parameters ($default) are the default values, and the second parameter is optional; if you do not fill in the parameters, you will get an array of get data.
Yii::$app->request->queryParams
The result is an array, which is equal to Yii::$app->request->get().
Recommended tutorial: yii framework
Post:
Yii::$app->request->post($key, $default)
The first parameter ($key) is The key of the user's post request, the first parameter is optional, the second parameter ($default) is the default value, and the second parameter is optional; if you do not fill in the parameters, you will get an array of post data.
Yii::$app->request->bodyParams
The result is an array, which is equal to Yii::$app->request->post().
For more programming related content, please pay attention to the Programming Introduction column on the php Chinese website!
The above is the detailed content of How to obtain user get and post parameters in yii2. For more information, please follow other related articles on the PHP Chinese website!