smarty模板的第一个demo的简单应用
1,下好的压缩包解压之后是这样的:

目录中,demo文件夹为示例文件。Libs为程序文件。
/libs/Smarty.class.php #主文件
/libs/sysplugins/ #内部plugin
/libs /plugins/ #外部plugin,可自由扩充
我们只需要用到libs包,把libs包放到自己项目的根目录
打开Smarty.class.php文件:
查看构造函数

/cahce/ #放置缓存文件
/configs / #放置可以载入的配置文件
/templates/ #放置模板文件
/templates_c/ #放置对模板编译后的文件
2,在libs根目录下新建这四个文件夹

3,在template模板文件里新建test.html文件
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
我们网站的网址是:{$add}
</body>
</html>4,根目录下新建test.php文件
代码如下:
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/3/12 0012
* Time: 下午 12:56
*/
require './libs/Smarty.class.php';
$smarty=new Smarty();
$add='www.php.cn';
$smarty->assign( 'add' , $add );
$smarty->display('./templates/test.html');5,运行index.php
展示如下:


大白兔
有一个错误,创建的是test.php却让访问index.php,希望改下
7年前 添加回复 0