Unknown filter with ID

Description

filter_var_array(), and other filter functions, use the second argument to identify which filter to apply. They are usually provided as constants, such as FILTER_SANITIZE_STRING. There are a limited, although long, set of such constants, and not all integer values are used. This is the case for -1.

Example

<?php

var_dump(filter_var_array(array(=>), 128));

?>

Literal Examples

  • Unknown filter with ID -1

  • Unknown filter with ID 128

Solutions

  • Use a valid constant to specify the filter.

  • Do not use literal integers, but constants.