?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
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.
編譯函數(shù)僅在模板編譯過程中被調(diào)用。對(duì)于將PHP代碼或?qū)r(shí)間敏感的靜態(tài)內(nèi)容嵌入到模板中,他們是比較有用的。如果編譯函數(shù)和普通函數(shù)都注冊(cè)了同一個(gè)名字,則編譯函數(shù)具有優(yōu)先使用權(quán)。
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.
此編譯函數(shù)有兩個(gè)參數(shù):標(biāo)記參數(shù)字符串——基本上是從函數(shù)名字直到結(jié)束位置的所有內(nèi)容,另一個(gè)參數(shù)是Smarty對(duì)象。該函數(shù)將返回嵌入到被編譯模板中的PHP代碼。
See also register_compiler_function(), unregister_compiler_function().
Example 16-6. simple compiler function簡(jiǎn)單編譯函數(shù)
This function can be called from the template as:
The resulting PHP code in the compiled template would be something like this:
|