?
Ce document utilise Manuel du site Web PHP chinois Libérer
Attribute Name | Type | Required | Default | Description |
---|---|---|---|---|
file | string | Yes | n/a | The name of the template file to include |
assign | string | No | n/a | The name of the variable that the output of include will be assigned to |
[var ...] | [var type] | No | n/a | variable to pass local to template |
屬性 | 類型 | 是否必須 | 缺省值 | 描述 |
---|---|---|---|---|
file | string | Yes | n/a | 待包含的模板文件名 |
assign | string | No | n/a | 該屬性指定一個變量保存待包含模板的輸出 |
[var ...] | [var type] | No | n/a | 傳遞給待包含模板的本地參數(shù),只在待包含模板中有效 |
Include tags are used for including other templates in the current template. Any variables available in the current template are also available within the included template. The include tag must have the attribute "file", which contains the template resource path.
Include 標簽用于在當前模板中包含其它模板. 當前模板中的變量在被包含的模板中可用. 必須指定 file 屬性,該屬性指明模板資源的位置.
You can optionally pass the assign attribute, which will specify a template variable name that the output of include will be assigned to instead of displayed.
如果設(shè)置了 assign 屬性,該屬性對應(yīng)的變量名用于保存待包含模板的輸出,這樣待包含模板的輸出就不會直接顯示了。
Example 7-6. function include
|
You can also pass variables to included templates as attributes. Any variables explicitly passed to an included template as attributes are only available within the scope of the included file. Attribute variables override current template variables, in the case they are named alike.
可以在屬性中傳遞參數(shù)給待包含模板. 傳遞給待包含模板的參數(shù)只在待包含模板中可見. 如果傳遞的參數(shù)在待包含模板中有同名變量,那么該變量被傳遞的參數(shù)替代.
Example 7-7. function include passing variables
|
Use the syntax for template resources to include files outside of the $template_dir directory.
包含 $template_dir 文件夾之外的模板請使用 模板資源 說明的格式.
Example 7-8. function include template resource examples
|