#### 視圖安全
```
public function actionTest()
{
$data['msg'] = '<script>alert("hello")</script>>';
return $this->renderPartial('index',$data);
}
```
```
<?= $msg; ?>
```
結果:彈出窗口

如下使用就會對字符串進行轉義
```
<?php
use \yii\helpers\Html;
use \yii\helpers\HTMLPurifier;
?>
<?= \yii\helpers\Html::encode($msg); ?>
<?= HTMLPurifier::process($msg); ?> //將html代碼徹底移除掉
```
效果
