Php Smarty first-time experience 2 get configuration information

Source: Internet
Author: User

First view results --

The page source code is as follows:

Analyze the code. After checking that the index_config.php (Smarty connection file) and index. php files are correct, let's take a look at the template file. The possible reason is that the tpl file generates the code --
Copy codeThe Code is as follows:
{% Config_load file = "1. conf" section = "style2" %}
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title >{% # title #%}</title>
</Head>
<Body bgcolor = "{%# bgcolor #%}" >{% $ hello %}
{% * This is a comment statement * %}
<Br/>
{% $ Array.0.0 %}
</Body>
</Html>

Smarty cannot parse the variables in the template file into the corresponding values. It must be an error when calling the file, but the code you write is correct, it is almost the same as the one on the book and on the Internet. How can I make a mistake ??

When I was puzzled, I suddenly found that when I called the variables, my code had more space than they did ..............................

Delete spaces, as shown in the following figure:

Page source code

In summary, when using the Smarty template, do not add spaces for the appearance and readability of the Code, so that Smarty will not parse these as variables, but will directly output

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.