yii2的框架笔记整理

1 .$request = Yii::$app->request;

2. get参数的获取方式 $id = $request->get('id',1);获取get的id,默认1

3 .post参数的获取方式 $id = $request->post('id',1); 获取post的id,默认1

4. 判断是否为get或者post的请求 $request->isGet; $request->isPost ; 是为true,否为false

5. 获取用户ip $request->userIP;

6. 将后台数据传递到前台 return $this->renderPartial('index',$data);  return $this->render('index',$data);  $data表示传递到前台的数据

7. compact 合并数组

8. 前台    <?php  echo \Yii\helpers\Html::encode($str) ?>将$str的html标签

猜你喜欢

转载自www.cnblogs.com/fpcing/p/8989278.html