©
이 문서에서는 PHP 중국어 웹사이트 매뉴얼 풀어 주다
Compiler functions are called only during compilation of the template.
They are useful for injecting PHP code or time-sensitive static
content into the template. If there is both a compiler function and a
custom function registered under the same name, the compiler function
has precedence.
编译函数仅在模板编译过程中被调用。对于将PHP代码或对时间敏感的静态内容嵌入到模板中,他们是比较有用的。如果编译函数和普通函数都注册了同一个名字,则编译函数具有优先使用权。
mixed smarty_compiler_
name
(string $tag_arg, object &$smarty)
The compiler function is passed two parameters: the tag argument
string - basically, everything from the function name until the ending
delimiter, and the Smarty object. It's supposed to return the PHP code
to be injected into the compiled template.
此编译函数有两个参数:标记参数字符串——基本上是从函数名字直到结束位置的所有内容,另一个参数是Smarty对象。该函数将返回嵌入到被编译模板中的PHP代码。
See also register_compiler_function(), unregister_compiler_function().
Example 16-6. simple compiler function简单编译函数
This function can be called from the template as:
The resulting PHP code in the compiled template would be something like this:
|