完全清除_POST数组 [英] Clearing _POST array fully

查看:91
本文介绍了完全清除_POST数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想完全清除$ _POST数组的内容,我在互联网上看到的所有示例都看起来像这样:

I want clear $_POST array content fully, all examples what I see in internet, looks like this:

if (count($_POST) > 0) {
    foreach ($_POST as $k=>$v) {
        unset($_POST[$k]);
    }
}

请告诉我,这种变体会更好吗? (从节省资源的角度来看)

Tell please, this variant will be not more better? (Point of view as saving resources)

if (count($_POST) > 0) {
     $_POST = array();
}

还是不?

推荐答案

是的,很好. $_POST只是另一个变量,除了它具有( super )全局范围.

Yes, that is fine. $_POST is just another variable, except it has (super)global scope.

$_POST = array();

...就足够了.该循环是无用的.最好将其保留为数组而不是取消设置,以防其他文件尝试读取它并假定它是数组.

...will be quite enough. The loop is useless. It's probably best to keep it as an array rather than unset it, in case other files are attempting to read it and assuming it is an array.

这篇关于完全清除_POST数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆