Clearing _POST array fully

前端 未结 6 992
面向向阳花
面向向阳花 2020-12-05 10:17

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)          


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 10:39

    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.

提交回复
热议问题