I've got a function that takes a filter constant for filter_input as an optional parameter. Is it possible to make sure the value of the string is a valid PHP filter constant, perhaps with a built in PHP function?
I know one way is to make my own array of all filter constants and check against that, but I was hoping for an easier or better way.
You could verify against the list of filters:
Where
$filtercontains the user supplied filter value and$validthe result as a bool (trueif valid,falseif invalid).See
filter_list()in the PHP manual for more details.