Think PHP 学习笔记 15.模板变量的详解

1.标量的输出

//模块
$arr = array('k1'=>'小赵1','k2'=>小赵2);
$this->assign('name',$arr);
$this->display();

//模板
{$name.k1}
{$name[k1]}

2.对象的输出

//模块
//对象的输出
//1. 建立一个My文件夹 位置'ThinkPHP/Extend/Library/ORG'
//2. 在My里,建立文件'Test.class.php'
class Test{
        public $k = '定义的对象!!';
    }
//3.
import('ORG.My.Test');
$obj=new Test;
$this->assign('name',$obj);
$this->display();

//模块
{$name:k}

系统变量

//模板
{$Think.get.na}
{$Think.const} 

加密

//模板
{$number|md5}

时间戳

//模块
$this->assgin('name',time());
$this->display();

//模板
// data [时间的格式] [### 现在的时间]
{$name|date='Y-m-d H:i:s',###}

运算符

//模块
$this->assign('nub',12);
$this->display();

//模板
{$nub + 5}
posted @ 2022-12-06 22:23  轻风细雨_林木木  阅读(62)  评论(0编辑  收藏  举报