Today in the use of Smarty to make a website, because there is such a need include file= "dynamic Path", which need to use variables in the value of file, try to solve a half-day finally, I think the method is more ingenious, the former use of the smarty is not so used, I hereby record it.
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"
These two kinds of writing are wrong, the use of variables directly in the template is not feasible, we can write in the php file. The final correct wording is as follows:
In the php file, you can write this:
$header = $path. ' header.dwt '; $smarty->assign (' header ', $header);
This is written in the template file:
{Include file= $header}
Articles you may be interested in
- Use PHP functions in Smarty Templates and how to use multiple functions for a variable in a smarty template
- Smarty Template Retention Variables Summary
- Smarty Variable operator Summary
- Firefox Tip event is not defined error resolution
- PHP fatal error allowed memory size of ... How memory-deficient errors should be resolved
- Smarty Template Variable operator summary
- Select into from prompt undeclared variable ..... The wrong solution
- Summary of System variables commonly used in thinkphp templates
http://www.bkjia.com/PHPjc/764077.html www.bkjia.com true http://www.bkjia.com/PHPjc/764077.html techarticle today when using Smarty to make a website, because there is such a need include file= "dynamic Path", which need to use variables in the value of file, try to finally solve, since ...