# # ThinkPHP 3.1.2 模板中的基本语法 # 讲师:赵桐正 微博:http://weibo.com/zhaotongzheng 本节课大纲: 一、导入CSS和JS文件 1、css link js scr 2.import
2.volist {$j} abc
egt elt 范围!
下面的这些了解即可!
3.present
标签来判断模板变量是否已经赋值,
4.Empty
empty标签判断模板变量是否为空,
5.Defined
判断常量是否已经定义
6.Define
在模板中定义常量
7.Assing
模板中变量赋值
Assign标签// <![CDATA[
$(function(){ $(window).resize(function(){ $(‘.book-content’).css(‘min-height’, $(window).height() - 130); }).resize(); //表格隔行变色 $(‘table’).TableColor(); //代码高亮 prettyPrint(); }); //表格隔行变色插件 $.fn.TableColor = function(){ return $(this).each(function(){ if(this.nodeName.toLowerCase() != ‘table’) return; var self = $(this); self.find(‘tr’).each(function(index) { var _this = $(this); if(index % 2 == 0){ _this.addClass(‘add’); } else { _this.addClass(‘even’); } _this.hover( function(){_this.addClass(‘hover’)}, function(){_this.removeClass(‘hover’)} ); }); }); }
// ]]>
五、其他标签使用 最好不要直接在模板中 使用php标签!!!因为这里是框架开发!一定要注意! 使用PHP代码// <![CDATA[ $(function(){ $(window).resize(function(){ $(‘.book-content’).css(‘min-height’, $(window).height() - 130); }).resize(); //表格隔行变色 $(‘table’).TableColor(); //代码高亮 prettyPrint(); }); //表格隔行变色插件 $.fn.TableColor = function(){ return $(this).each(function(){ if(this.nodeName.toLowerCase() != ‘table’) return; var self = $(this); self.find(‘tr’).each(function(index) { var _this = $(this); if(index % 2 == 0){ _this.addClass(‘add’); } else { _this.addClass(‘even’); } _this.hover( function(){_this.addClass(‘hover’)}, function(){_this.removeClass(‘hover’)} ); }); }); } // ]]>
简而言之,在PHP标签里面不能再使用PHP本身不支持的代码!!! 如果设置了TMPL_DENY_PHP参数为true,就不能在模板中使用原生的PHP代码,但是仍然支持PHP标签输出!(了解)
1、在模板中直接使用PHP代码