Search Results

  1. Filters a variable with a specified filter

  2. Definition and Usage The filter_var () function filters a variable with the specified filter.

  3. www.phptutorial.netphp-tutorial › php-filter_varPHP filter_var Function

    In this tutorial, you will learn how to use the PHP filter_var() function to sanitize and validate data.

  4. Mar 17, 2026 · Parameters value Value to filter. Note that 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 will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no filtering taking place by default. options Associative array of options ...

  5. Below, we will consider several use cases of the filter_var () function. Sanitizing a String In the example, demonstrated below, you can see how to sanitize a string with filter_var (): It will remove all HTML tags from the string.

  6. Jan 29, 2026 · The filter_var() function is part of PHP's filter extension, which provides a set of functions to validate and sanitize data. The primary purpose of filter_var() is to perform both validation and sanitization based on the specified filter type.

  7. People also ask

  8. Nov 18, 2019 · The filter_var () function filters a variable with the specified filter. This function is used to both validate and sanitize the data. Syntax :- filter_var(var, filtername, options) Parameters: This function accepts three parameters and are described below: var : It is the required field. It denotes the variable to filter.