开发者

how can i Filter and escape all input data in mvc pattern?

开发者 https://www.devze.com 2023-03-31 00:39 出处:网络
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 ve

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消