The problem I see with this implementation has to do with code readability and maintenance. There are two very nice things about using the POST and GET variables directly instead of copying them into a separate variable. First is that it will be easy to forget this step and it is likely to be implemented unevenly. That is, for new developers they are likely to just use _POST or _GET instead of using the get_input function.
The second is that for code readability, you lose the context of the variable when you copy it into another variable. Now instead of being able to easily see that a variable is part of the POST array, I have to look around and see if the post variable has been copied into that variable.
Am I all alone in thinking that uniformly removing or adding all slashes to the POST and GET variables once at the top of the program is a better implementation than modifying every line of code that uses these variables?
-Charles
David Charbonnier wrote:
I'd prefer a generic function like get_form_input($name) which does something like the solution posted by dc.ml[at]oxys.net but with also with GET parameters: $in = !empty($_POST[$name]) ? $_POST[$name] : $_GET[$name];
I don't like the idea to don't know from which method are data. I don't use $_REQUEST and your solution is $_REQUEST equivalent.
If you prefer, we can do get_input($name,$method='A') 'A' is for All with EGPCS order, and the equivalent of your code should be 'PG'
Agree. This would be a good solution.
So ? I do it ? Does everybody approve this solution ?
David