Frame notes for yii2

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

2. How to get the get parameter $id = $request->get('id',1); Get the id of get, the default is 1

3. How to get the post parameter $id = $request->post('id',1); Get the id of the post, the default is 1

4. Determine whether it is a get or post request $request->isGet; $request->isPost ; is true, otherwise false

5. Get user ip $request->userIP;

6. Pass the background data to the foreground return $this->renderPartial('index',$data); return $this->render('index',$data); $data represents the data passed to the foreground

7. compact merge array

8. The foreground <?php echo \Yii\helpers\Html::encode($str) ?> put the html tag of $str

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325237899&siteId=291194637