YII学习总结5(视图)
2024-09-06 11:47:11
<?php
namespace app\controllers;
use yii\web\Controller; class HelloController extends Controller
{
public function actionIndex()
{
$hellp_str = "hello God!"; $data = array(); $data["view_hello_str"] = $hello_str; return $this->renderPartial("index",$data);
}
}
?> views\hello\index.php $helper_str = "hello world!<script>console.log(111);</script>" <?php
use yii\helpers\Html;//转义
use yii\helpers\HtmlPurifier;//过滤html <h1><?= Html::encode($view_hello_str);?></h1> <!--Html::encode() 能防止跨站脚本攻击,转义html标签-->
<h1><?= HtmlPurifier::process($view_hello_str);?></h1>
<?= $this->render('_overview') ?><!--在一个视图中调用另一个视图-->
禁用布局
控制器内控制 public $layout=false/'layout'
控制器成员方法内控制 $this->layout=false/'layout'
视图中选择布局 $this->context->layout=false/'layout'
最新文章
- REq,RES编码设置
- [Unity] 精灵动画制作中需要注意的一些问题
- canvas draw a image
- C166 Interfacing C to Assembler
- ios Swift 资源池
- Implement the hash table using array / binary search tree
- webstrom 编码
- 解决关于win10下eclipse代码格式化不生效问题
- MySQL Sending data导致查询很慢的问题详细分析【转载】
- java中的Condition协作线程接口类
- 本科理工男如何学习Linux
- 文件-- 字节相互转换(word、图片、pdf...)
- django----数据库操作(对model增删改查)
- Java判断一个字符串中有多少大写字母、小写字母和数字
- Docker制作私有的基础镜像
- struts2的MVC模式
- 设计模式 结构型模式 外观模式(Facade Pattern)
- 20165233 Java第四章学习总结
- Linux命令详解-touch
- GPU编程自学4 —— CUDA核函数运行参数