Smarty include file methods for using Variables _php tutorial

Source: Internet
Author: User
Tags smarty template
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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.