Home > Backend Development > PHP Tutorial > smarty include file How to use variables_PHP tutorial

smarty include file How to use variables_PHP tutorial

WBOY
Release: 2016-07-13 10:31:25
Original
1074 people have browsed it

When I was using smarty to build a website today, there was a need to include file="dynamic path", which required using variables in the value of file. After trying for a long time, I finally solved it. I think the method is It's quite clever. I've never used smarty like this before, so I'll record it here.

Let’s talk about how to use variables in the value of include file!

include file={$path}"header.dwt" or include file="{$path}header.dwt"

The above two ways of writing are wrong. Using variables directly in the template does not work. We can write it in a php file. The final correct writing is as follows:

You can write this in the php file:

$header=$path.'header.dwt';
$smarty->assign('header',$header);
Copy after login

is written like this in the template file:

{include file=$header}
Copy after login

Articles you may be interested in

  • Using php functions in smarty templates and how to use multiple functions for one variable in smarty templates
  • Smarty template retained variable summary
  • Smarty variable operator summary
  • Firefox prompts event is not defined error solution
  • PHP reports Fatal error Allowed memory size of...What should I do if there is insufficient memory error? Solution to
  • Smarty template variable operator summary
  • select into from prompt Undeclared variable.... Error solution
  • Summary of system variables commonly used in Thinkphp templates

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764077.htmlTechArticleWhen I was using smarty to build a website today, there was a need to include file="dynamic path". This You need to use variables in the value of file. After trying for a long time, I finally solved it. Since...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template