<?php
use yii\helpers\Html;
use yii\helpers\HtmlPurifier;
?>
<h1>Hello index view</h1>
<h2>姓名:<?php echo $name;?></h2>
<h2>年龄:<?=$age?></h2>
<h2>地址:<?=$address[0]?> <?=$address[1]?></h2>
<h2>简介:<?=Html::encode($intro)?> </h2>
<h2>简介:<?=HtmlPurifier::process($intro)?> </h2>
Yii 视图布局
控制器代码:
//设置的布局文件
public $layout = 'common';
public function actionAbout(){
$data = array('page_name'=>'About');
//render方法会把视图文件common的内容放到$content当中,并显示布局文件。
return $this->render('about',$data);
}
public $layout = 'common';
public function actionStudent(){
$data = array('page_name'=>'Student');
return $this->render('student',$data);
}
public function actionTeacher(){
$data = array('page_name'=>'Teacher');
return $this->render('teacher',$data);
}