Skip to content
fjarrett edited this page Sep 8, 2014 · 5 revisions

wp_stream_filter_input()

Gets a specific external variable by name and optionally filters it.

This is a polyfill function intended to be used in place of PHP's filter_input() function, which can occasionally be unreliable. See issue #257 for more info.

Return

(mixed) Value of the requested variable on success, FALSE if the filter fails, or NULL if the $variable_name is not set.

Params

$type (int) One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.

$variable_name (string) Name of a variable to get.

$filter (int) The ID of the filter to apply. The Types of filters manual page lists the available filters.

$options (mixed) Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array.

Changelog

Since: 1.2.5

Source file: includes/functions.php

wp_stream_filter_input( $type, $variable_name, $filter = null, $options = array() );

wp_stream_filter_var()

Filters a variable with a specified filter.

This is a polyfill function intended to be used in place of PHP's filter_var() function, which can occasionally be unreliable. See issue #257 for more info.

Return

(mixed) Returns the filtered data, or FALSE if the filter fails.

Params

$var (string) Value to filter.

$filter (int) The ID of the filter to apply. The Types of filters manual page lists the available filters.

$options (mixed) 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, callable type should be passed. The callback must accept one argument, the value to be filtered, and return the value after filtering/sanitizing it.

Changelog

Since: 1.2.5

Source file: includes/functions.php

wp_stream_filter_var( $var, $filter = null, $options = array() );