thinkphp output variable

Overview The global input variable detection, acquisition and security filtering

can be completed through the Request object, including system variables such as $_GET, $_POST, $_REQUEST, $_SERVER, $_SESSION, $_COOKIE, $_ENV, and file upload information.
Detecting whether a variable is set

You can use the has method to detect whether a variable parameter is set, as follows:
Request::instance()->has('id','get');
Request::instance()->has('name','post');

or use a helper function

input('?get.id');
input('?post.name');

Variable detection can support all supported system variables.
Variable acquisition

Variable acquisition uses the following methods and parameters of the \think\Request class:

    Variable type method ('variable name/variable modifier', 'default value', 'filter method')

Variable type methods include:
method description
param Get current request
get $_GET variable post
get $_POST variable
put get PUT variable
delete get DELETE variable
session get $_SESSION variable
cookie get $_COOKIE variable
request get $_REQUEST variable
server get $_SERVER variable
env get $_ENV variable
route get route (including PATHINFO) variable
file Get $_FILES variable
Get PARAM variable

PARAM variable is a variable acquisition method provided by the framework to automatically identify GET, POST or PUT requests. It is the recommended method of the system to get request parameters. The usage is as follows:
// Get the name variable of the current request
Request::instance()->param('name');
// Get all variables of the current request (filtered)
Request::instance()->param();
// Get all variables of the current request (raw data)
Request::instance()->param(false);
// Get all variables of the current request (including uploaded files)
Request::instance()->param(true);

    The param method will combine the parameters of the current request type with the PATH_INFO variable and the GET request.

Use a helper function to achieve:

input('param.name');
input('param.');
or
input('name');
input('');

Because the input function uses the PARAM variable reading method by default.

get GET variable
Request::instance()->get('id'); // Get a get variable
Request::instance()->get('name'); // Get the get variable
Request::instance()->get(); // Get all get variables (filtered array)
Request::instance()->get(false); // Get all get variables (original array)

Or use the built-in helper function input method to achieve the same functionality:

input('get.id');
input('get.name');
input('get.');

    Note: The pathinfo address parameter cannot be obtained through the get method, see "Get PARAM Variables"

to obtain POST variables
Request::instance()->post('name'); // Get a post variable
Request::instance()->post(); // Get all filtered post variables
Request::instance()->post(false); // Get all the original post variables

Use a helper function to achieve:

input('post.name');
input('post.');

Get PUT variable
Request::instance()->put('name'); // Get a put variable
Request::instance()->put(); // Get all put variables (filtered)
Request::instance()->put(false); // Get all put primitive variables

Use a helper function to achieve:

input('put.name');
input('put.');

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326549213&siteId=291194637