I am wondering if it is possible to get a variable, whether it is in POST or GET, and then use filter_input () to clear it.
At first I thought that $var = filter_input(INPUT_POST | INPUT_GET, "var", FILTER_SANITIZE_STRING) might work, but it is not, and the PHP manual says that you can only pass one type of input.
I also tried INPUT_REQUEST , which strangely didn't work. The function recognizes it (i.e. it does not cause an error saying that I put something wrong in $ input), but it will not receive any code. And yes, I know that I do not use INPUT_REQUEST in a live environment, I just simply tested whether this would work.
I am currently doing the following:
$var = filter_input(INPUT_POST, "var", FILTER_SANITIZE_STRING); if(!$var) $var = filter_input(INPUT_GET, "var", FILTER_SANITIZE_STRING);
however, with many things in PHP, there is often an easier way that will make all of this one command for me. I am wondering if this is so, can I combine them into one check? I did a quick Google search and couldn’t even find links to those who tried to do this before, not to mention the solution, so now I am contacting you with good people.
source share