Smarty快速入门
1.Smarty是用纯php语言写的类
2.功能是实现前后端分离
3.Smarty简洁高效
4.快速入门案例
1.下载 smarty源码 https://www.smarty.net/
2.搭建PHP环境 xampp 这里用集成环境.其他 亦可。https://www.apachefriends.org/index.html 下载地址
3.在xampp/hodocs/ 创建目录 Demo
4.把下载的Smarty源码 中的libs拷贝到Demo 文件中
5.代码演示:
在Demo中创建index.php文件
<?php
#引入Smarty类
include "./libs/Smarty.class.php";
#创建smarty实例
$smarty = new Smarty;
#对Smarty进行配置
#模版路径设置
$smarty->template_dir = "./templates";
#混编目录设置
$smarty->compile_dir = "./compiles";
#边界符号设置
#左边界符号
$smarty->left_delimiter = "<{";
#右边界符号
$smarty->right_delimiter = "}>";
#给模版赋值变量
$smarty->assign("title",“我是从模版哪儿过来的!”);
$smarty->assign("h1",“我是从模版哪儿过来的h1!”);
#显示
$smarty->display("index.tpl");
?>
#到此应该在相应的目录中创建模版文件夹和 混编文件夹(这里是当前目录下)
#在templates 文件夹下创建模版文件 index.tpl(后缀名 没限制)
#index.tpl:代码 如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><{$title}></title>
</head>
<body>
<h1><{$h1}></h1>
</body>
</html>
#---------------------------------------------------------------------------------------------------#
在浏览器中:http://127.0.0.1/Demo 运行 (这里是本机 端口默认80)
最新文章
- jQuery-1.9.1源码分析系列完毕目录整理
- java关键包简易说明
- Gobblin采集kafka数据
- Vim插件管理
- PAT 1072. Gas Station (30)
- PHP检测每一段代码执行时间
- 主动模式下FTP的详细工作过程(转) 挺详细
- rails之 Migrations (转)
- C# 利用BarcodeLib.dll生成条形码(一维,zxing,QrCodeNet/dll二维码)
- apache安装 mod_evasive
- poj 1300 Door Man 欧拉回路
- PHP组合模式
- 通过Java SE 7自带的监控服务(WatchService API)实现类似.NET FileWatcher的功能
- 圣诞福利到!51Testing邀你一起来狂欢!有礼就是任性~(≧▽≦)/~
- Redis和Memcached区别
- C#基础第二天
- 虚拟机安装精简版centos7过程
- Ansible运维自动化
- May 28. 2018 Week 22nd Monday
- (点到线段的最短距离)51nod1298 圆与三角形
热门文章
- 安装tensorflow遇到:Your CPU supports instructions that this TensorFlow binary was not compiled to use
- 一些需要禁用的PHP危险函数(disable_functions)
- JQuery操作DOM(8)
- 免费馅饼~-~ (hdu 1176
- Inter IPP 绘图 ippi/ipps
- LeetCode 88. 合并两个有序数组(Merge Sorted Array)
- Anaconda官网下载太慢/出错,以及Anaconda下载包又慢又出错的总体方法,应该如何快速下载,使用上海科技大学的开源镜像站即可
- Qt第三方库libvlc-qt——ubuntu上编译、安装,测试
- MapInfo 文件解析
- android data binding jetpack I 环境配置 model-view 简单绑定