filter_var
Function • Params and return types changed in PHP 8.0
Filters a variable with a specified filter.
filter_var Function synopsis
filter_var(
mixed $value,
int $filter = FILTER_DEFAULT,
array|int $options = 0
): mixed
Parameters
$value
Typemixed
$filter
OptionalTypeintDefault valueFILTER_DEFAULT
$options
OptionalTypearray|intDefault value0
Return value
Typemixed
Changes to the filter_var Function
PHP 8.0
- Return type added:
mixed - Parameter name of parameter #1 changed:
$variableto$value - Parameter type added for parameter #1 (
$value):mixed - Parameter type added for parameter #2 (
$filter):int - Parameter default value added for position #2 (
$filter):FILTER_DEFAULT - Parameter type added for parameter #3 (
$options):array|int - Parameter default value added for position #3 (
$options):0
filter_var(
- $variable,
+ mixed $value,
- $filter,
+ int $filter = FILTER_DEFAULT,
- $options
+ array|int $options = 0
- )
+ ): mixed filter_var Function Availability
filter_var Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |