我正在使用 CHttpException(404, $message) 行处理 404,$message 变量是一个 HTML 字符串,用于实现一些样式。但是 CHttpException() 对我的 $message 进行编码,将 HTML 呈现为无用的转义字符串。为了输出 HTML,有什么办法可以绕过 CHttpException 的字符串编码?
/**
* From PostsController.php
*/
// ...
public function actionCategory($id)
{
$categoryModel = Categories::model()->findByAttributes(array('idCategory'=>$id));
if($categoryModel===null){
$message = "<div class=\"alert alert-danger\">Page Not Found</div>";
throw new CHttpException(404, $message);
return;
}
// ...