一 代码
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文件
<?php
include_once '../config.php';
$smarty->display('4/index.tpl');
?>
二 运行结果