Home > php教程 > php手册 > smarty内置函数config_load用法实例,smartyconfig_load

smarty内置函数config_load用法实例,smartyconfig_load

WBOY
Release: 2016-06-13 09:16:41
Original
1195 people have browsed it

smarty内置函数config_load用法实例,smartyconfig_load

本文实例讲述了smarty内置函数config_load用法。分享给大家供大家参考。具体如下:

{config_load}用于从配置文件中,加载到配置变量。详细用法如下:
配置文件:foo.conf

说明:[Table] 和 [Customer] 表示段落名称。

复制代码 代码如下:

[Table]
pageTitle = "this is mine"
bodyBgColor = "#eee"
tableBorderSize = 3
tableBgColor = "#bbb"
rowBgColor = "#ccc"

[Customer]
pageTitle = "Customer Info"

模板文件:temp.htm

复制代码 代码如下:

{config_load file="foo.conf"}
{#pageTitle#}
{#bodyBgColor#}


第一种引入方法:错误。如果配置文件中每个段落都有名称,则必须加上 section="段落名称",才能加载到变量。

复制代码 代码如下:

{config_load file="foo.conf" section="Customer"}
{#pageTitle#}
{config_load file="foo.conf" section="Table"}
{#pageTitle#}


第二种加载方法,正确。加载相应的段落,引入相应的变量。

希望本文所述对大家的php程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template