Filters and filter functions

suggest change

Versions

The original topic was tagged for PHP 5.0 through 7.1. The filter extension has shipped with PHP since 5.2.

Introduction

This extension filters data by either validating or sanitizing it. This is especially useful when the data source contains unknown (or foreign) data, like user supplied input. For example, this data may come from an HTML form.

Syntax

Parameters

Parameter Details
variable Value to filter. Scalar values are converted to string internally before they are filtered.
filter The ID of the filter to apply. The Types of filters manual page lists the available filters. If omitted, FILTER_DEFAULT is used, which is the same as FILTER_UNSAFE_RAW, so nothing is filtered.
options An associative array of options, or a bitwise OR of flags. If the filter accepts options, pass flags in the array’s "flags" field. For the "callback" filter, pass a callable. It receives the value and returns the filtered value.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents