?
This document uses PHP Chinese website manual Release
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代碼或對時間敏感的靜態(tài)內容嵌入到模板中,他們是比較有用的。如果編譯函數和普通函數都注冊了同一個名字,則編譯函數具有優(yōu)先使用權。
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:
|