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

How to obtain user get and post parameters in yii2

王林
Release: 2020-02-19 14:57:17
Original
4097 people have browsed it

How to obtain user get and post parameters in yii2

Get:

Yii::$app->request->get($key, $default)
Copy after login

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
Copy after login

The result is an array, which is equal to Yii::$app->request->get().

Recommended tutorial: yii framework

Post:

Yii::$app->request->post($key, $default)
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template