ThinkPHP中的过滤函数[可以对对象,数组,字符串进行递归过滤]

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/aoyoo111/article/details/7272771

ThinkPHP中的过滤函数[可以对对象,数组,字符串进行递归过滤]

function inputFilter($content)
{
	if(is_string($content) ) {
        return Input::getVar($content);
    }
    elseif(is_array($content)){
        foreach ( $content as $key => $val ) {
            $content[$key] = inputFilter($val);
        }
        return $content;
    }
    elseif(is_object($content)) {
        $vars = get_object_vars($content);
        foreach($vars as $key=>$val) {
            $content->$key = inputFilter($val);
        }
        return $content;
    }
    else{
        return $content;
    }
}


展开阅读全文

没有更多推荐了,返回首页