yii-gpc处理

一,使用

Yii::app()->request->getParam('id');      //get,post
Yii::app()->request->getQuery('name');    //get
Yii::app()->request->getPost('name');     //post


二,源码

   CHttpRequest

   

        public function init(){
        parent::init();
        $this->normalizeRequest();
    }
        protected function normalizeRequest(){
        // normalize request
        //启动了自动转义则取消
        if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()){
            if(isset($_GET))
                $_GET=$this->stripSlashes($_GET);
            if(isset($_POST))
                $_POST=$this->stripSlashes($_POST);
            if(isset($_REQUEST))
                $_REQUEST=$this->stripSlashes($_REQUEST);
            if(isset($_COOKIE))
                $_COOKIE=$this->stripSlashes($_COOKIE);
        }
        if($this->enableCsrfValidation)
            Yii::app()->attachEventHandler('onBeginRequest',array($this,'validateCsrfToken'));
    }
public function getParam($name,$defaultValue=null){
    return isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $defaultValue);
}
public function getQuery($name,$defaultValue=null){
    return isset($_GET[$name]) ? $_GET[$name] : $defaultValue;
}
public function getPost($name,$defaultValue=null){
    return isset($_POST[$name]) ? $_POST[$name] : $defaultValue;
}


你可能感兴趣的:(yii,get,post)