AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
template() - 展示特定模板内容 ### 说明 ~~~ mixed function template(string $filename, int $flag = TEMPLATE_DISPLAY) ~~~ ### 参数 * **$filename**string 模板名称,格式为: ‘模板文件夹/模板名称无后缀’,如: ‘common/header’ * **$flag**int 模板展示方式 ### 返回值 ~~~ 调用PHP模板文件 ~~~ ### 说明 * **$flag** * **EMPLATE\_DISPLAY**导入全局变量,渲染并直接展示模板内容(默认值) * **TEMPLATE\_FETCH**导入全局变量,渲染模板内容,但不展示模板内容,而是将其作为返回值获取。 可用于静态化页面。 * **TEMPLATE\_INCLUDEPATH**不导入全局变量,也不渲染模板内容,只是将编译后的模板文件路径返回,返回的模板编译路径可以直接使用 include 嵌入至当前上下文。 ### 示例 以下三种调用方式效果相同 ~~~ // 直接展示模板template('common/template');// 获取模板渲染出的内容$content = template('common/template', TEMPLATE_FETCH);// 输出渲染的内容echo $content;// 嵌入模板编译路径include template('common/template', TEMPLATE_INCLUDEPATH); ~~~