Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use filter_input in php

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use filter_input in php". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how to use filter_input in php.

In PHP, the "filter_input ()" function is used to validate variables from non-secure sources, get input from outside the script, and filter, return filtered data for success and false for failure. The syntax is "filter_input (input type, filtered variable, filter ID, array)".

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

What is the use of filter_input in php

The filter_input () function takes input from outside the script and filters it.

This function is used to validate variables from non-secure sources, such as user input.

This function can get input from various sources:

INPUT_GET

INPUT_POST

INPUT_COOKIE

INPUT_ENV

INPUT_SERVER

INPUT_SESSION (Not yet implemented)

INPUT_REQUEST (Not yet implemented)

If successful, the filtered data is returned, if failed, false is returned, and NULL is returned if the variable parameter is not set.

Grammar

Filter_input (input_type, variable, filter, options)

Input_type is required. Specify the input type. See the possible types in the list above.

Variable specifies the variables to be filtered.

Filter is optional. Specifies the ID of the filter to be used. The default is FILTER_SANITIZE_STRING.

Options specifies an array containing flags / options. Check the possible flags and options for each filter.

Examples are as follows:

In this case, we use the filter_input () function to filter a POST variable. The accepted POST variable is a valid e-mail address.

The output is similar to:

E-Mail is valid

At this point, I believe you have a deeper understanding of "how to use filter_input in php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report