Smarty中include_php的使用???
以下是Smarty中include_php的源代码:
load_nav.php
<?php
// load in variables from a mysql db and assign them to the template
require_once("MySQL.class.php");
$sql = new MySQL;
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
$this->assign('sections',$sql->record);
?>
index.tpl
---------
{* absolute path, or relative to $trusted_dir *}
{include_php file="/path/to/load_nav.php"}
{foreach item="curr_section" from=$sections}
<a href="{$curr_section.url}">{$curr_section.name}</a><br>
{/foreach}
我不太清楚,这样做的好处是什么?
既然变量$sections已经传给Smarty模板文件了,那再在模板文件里包含PHP文件有什么作用呢?直接使用那个变量不就可以了吗?
能不能给几个include_php的例子,让我明白它的好处是什么,多谢。
load_nav.php
<?php
// load in variables from a mysql db and assign them to the template
require_once("MySQL.class.php");
$sql = new MySQL;
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
$this->assign('sections',$sql->record);
?>
index.tpl
---------
{* absolute path, or relative to $trusted_dir *}
{include_php file="/path/to/load_nav.php"}
{foreach item="curr_section" from=$sections}
<a href="{$curr_section.url}">{$curr_section.name}</a><br>
{/foreach}
我不太清楚,这样做的好处是什么?
既然变量$sections已经传给Smarty模板文件了,那再在模板文件里包含PHP文件有什么作用呢?直接使用那个变量不就可以了吗?
能不能给几个include_php的例子,让我明白它的好处是什么,多谢。
...全文
相关推荐
PHP之smarty配置
php----smarty模板的配置,学习的好助手
PHP 基于Yii框架中使用smarty模板的方法详解
本篇文章是对在Yii框架中使用smarty模板的方法进行了详细的分析介绍,需要的朋友参考下
PHP_smarty
smarty是一个使用PHP写出来的模板PHP模板引擎,它提供了逻辑与外在内容的分离,简单的讲,目的就是要使用PHP程序员同美工分离...
Smarty_smarty_
Smarty 模板引擎教程,内容主要有基本语法、变量、组合修改器、内建函数、自定义函数、配置文件、控制台调试、缓存、插件扩展、使用技巧和经验等,比较详细的一个中文手册
php smarty 最新版使用手册 latest
smarty 语法 配置 标签 方法 使用 自定义方法


基础编程
