how can i Filter and escape all input data in mvc pattern?
i am using my own mvc framework and i want to filter and escape all of the input and out put automatical开发者_高级运维ly. How do I?
Create a function which filters the data as you want. Then at the very beginning you put this code:
array_map('your_filter_function', $_REQUEST);
Alternatively you can create a class which wraps the post and get super globals. If I want to get a post variable in Codeigniter, for example, I do this:
$post_var = $this->input->post('key');
And the function post could if you wanted to filter the value before it retrieves it (return your_filter_function($_POST['key']));
Escaping output would be done by adding this feature to your database layer, or other sources of output.
精彩评论