Home >PHP Framework >YII >How to obtain user get and post parameters in yii2

How to obtain user get and post parameters in yii2

王林
王林Original
2020-02-19 14:57:174147browse

How to obtain user get and post parameters in yii2

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!

Statement:
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