smarty include file 使用变量的方法_PHP教程

WBOY
Libérer: 2016-07-13 10:31:25
original
1007 Les gens l'ont consulté

今天在用smarty做个网站的时候,由于有这么一个需要 include file="动态路径" ,这就需要在file的值里面使用变量了,尝试了半天终于解决,自己觉得方法还是比较巧妙的,以前用smarty的时候就没有这么用过,特此记录一下。

下面就说说如何在include file的值中使用变量的方法吧!

include file={$path}"header.dwt" 或者 include file="{$path}header.dwt"

以上这两种写法是错误的,在模板中直接使用变量行不通,我们可以在php文件中来写。最终正确写法如下:

在php文件中可以这么写:

$header=$path.'header.dwt';
$smarty->assign('header',$header);
Copier après la connexion

在模板文件中则这样写:

{include file=$header}
Copier après la connexion

您可能感兴趣的文章

  • smarty模板中使用php函数以及smarty模板中如何对一个变量使用多个函数
  • smarty模板保留变量总结
  • smarty变量操作符总结
  • Firefox 提示event is not defined错误的解决办法
  • PHP报Fatal error Allowed memory size of...内存不足的错误应该如何解决
  • Smarty模板变量操作符总结
  • select into from 提示 Undeclared variable.....错误的解决办法
  • Thinkphp 模板中常用的系统变量总结

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/764077.htmlTechArticle今天在用smarty做个网站的时候,由于有这么一个需要 include file="动态路径" ,这就需要在file的值里面使用变量了,尝试了半天终于解决,自...
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!