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

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;
    }
}


你可能感兴趣的:(function,object,String,input)