Yii::app()->request->getParam($name, $defaultValue)

转自http://blog.sina.com.cn/s/blog_7d85d15a0101ink1.html

一、YII自带的获取参数的方法:
1、Yii::app()->request->getParam($name, $defaultValue);
   其中 $name :参数名; $defaultValue :默认值。
例如:Yii::app()->request->getParam('userId',0); //获取用户id,默认值为0;
2、Yii::app()->request->getParam($name);
  也可以不设置默认值,直接接受传递过来的参数

3、$request = Yii::app()->getRequest();
   if ($request->isPostRequest && $request->isAjaxRequest) {
      $id = $request->getParam('id');
   }

注意
以上获取参数的方法并不能进行参数过滤,即不能避免恶意的参数注入

原文地址:https://www.cnblogs.com/yangbanban/p/4674066.html