eval

PHP Smarty

Smarty - the compiling PHP template engine
Smarty - php 模板编译引擎
Prev 来源:PHP中文社区 Chapter 8. Custom Functions[第八章.自定义函数] Next

eval

Attribute Name Type Required Default Description
var mixed Yes n/a variable (or string) to evaluate
assign string No n/a the template variable the output will be assigned to

属性 类型 是否必须 缺省值 描述
var mixed Yes n/a 待求值的变量(或字符串)
assign string No n/a 输出值将被赋给模板变量的名称
setup.conf
----------

emphstart = <b>
emphend = </b>
title = Welcome to {$company}'s home page!
ErrorCity = You must supply a {#emphstart#}city{#emphend#}.
ErrorState = You must supply a {#emphstart#}state{#emphend#}.


index.tpl
---------

{config_load file="setup.conf"}

{eval var=$foo}
{eval var=#title#}
{eval var=#ErrorCity#}
{eval var=#ErrorState# assign="state_error"}
{$state_error}

OUTPUT:

This is the contents of foo.
Welcome to Foobar Pub & Grill's home page!
You must supply a <b>city</b>.
You must supply a <b>state</b>.

Prev 来源:PHP中文社区 Home Next
debug Up fetch