Smarty读取配置文件

来源:互联网 发布:北京南街村方便面 知乎 编辑:程序博客网 时间:2024/05/16 19:03

一 代码

config文件
title = "调用配置文件"bgcolor = "#f0f0f0"border = "5"type = "计算机类"name = "PHP从入门到精通"
tpl模板文件
{config_load file="4.conf"}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>{#title#}</title><link rel="stylesheet" href="../css/style.css" /></head><body bgcolor="{#bgcolor#}"><table border="{#border#}"><tr><td>{$smarty.config.type}</td><td>{$smarty.config.name}</td></tr></table></body></html>
 
 
php文件
<?phpinclude_once '../config.php';$smarty->display('4/index.tpl');?>
 
二 运行结果

 
  • 大小: 9.5 KB
  • 查看图片附件
原创粉丝点击