filter_data

filter_data

(no version information, might be only in CVS)

filter_data -- Filters data with a specified filter

Description

mixed filter_data ( mixed variable, int filter [, mixed filter_options [, string charset]] )

Warning

This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

Parameters

variable

Value to filter, arrays are filtered resursivelly.

filter

ID of a filter to use.

filter_options

Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. For the "callback" filter, callback type should be passed.

charset

Character set used for filtering. Currently no filter uses this parameter.

Return Values

Returns filtered data or NULL if filter fails.

Examples

Example 1. A filter_data() example

<?php
var_dump
(filter_data('bob@example.com', FILTER_VALIDATE_EMAIL));
var_dump(filter_data('example.com', FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED));
?>

The above example will output:

string(15) "bob@example.com"
NULL

See Also

input_get()
information about the callback type

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.