Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the uses of the input method in thinkphp

Shulou Source: shulou.com Published: 2022-06-01 14:34:43 10月04日 Update

This article mainly explains "what are the uses of the input method in thinkphp". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the use of the input method in thinkphp".

The use of the input method in thinkphp: 1, to determine whether the variable is defined, the syntax is "input ('? post.name')"; 2, to obtain the PARAM parameter, the syntax is "input ('param.')"; 3, to obtain the GET parameter, the syntax is "input (' get.')".

This article operating environment: Windows10 system, ThinkPHP5 version, Dell G3 computer.

What is the use of the input method in thinkphp

1. Determine whether the variable is defined

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

Variable type methods include:

Method description: param get the currently requested variable get 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 $_ FILE variable

two。 Get the PARAM parameter

Input ('param.name'); / / get a single parameter input (' param.'); / / get all parameters / / here is the equivalent input ('name'); input ('')

3. Get the GET parameter

/ / get a single variable input ('get.id'); / / use the filtering method to get the default empty string input (' get.name'); / / get all variables input ('get.')

4. Use the filtering method

Input ('get.name','','htmlspecialchars'); / / get get variables and filter input (' username','','strip_tags') with the htmlspecialchars function; / / get param variables and filter input ('post.name','','org\ Filter::safeHtml') with the strip_tags function; / / get post variables and filter using the safeHtml method of the org\ Filter class

5. Use variable modifiers

Input ('get.id/d'); input (' post.name/s'); input ('post.ids/a'); modifier s cast to string type d cast to integer type b cast to Boolean type a cast to array type f cast to floating point type

Thank you for your reading, the above is the content of "what is the use of input method in thinkphp". After the study of this article, I believe you have a deeper understanding of the use of input method in thinkphp, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Variables methods uses parameters types compulsions syntax learning content functions single action characters strings that is Boolean ideas situations arrays articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi MySQL Redmi Shulou Tech Info