PhpSmarty first-time experience 2 get configuration information _ php template_script house

Source: Internet
Author: User
The features of the Smarty template determine its superiority, which is also the reason why PHPer is sought after (more importantly, most of the recruitment requirements). Today, I roughly read the basic usage of Smarty, however, it was useless to watch it. I tried it at noon, but it turned out to be a small problem, which caused me no time to go to bed at noon.

The features of the Smarty template determine its superiority, which is also the reason why PHPer is sought after (more importantly, most of the recruitment requirements). Today, I roughly read the basic usage of Smarty, however, it was useless to watch it. I tried it at noon, but it turned out to be a small problem, which caused me no time to go to bed at noon.

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 --
The Code is as follows:
{% Config_load file = "1. conf" section = "style2" %}



{% # Title # %}

{% $ Hello %}
{% * This is a comment statement * %}


{% $ Array.0.0 %}



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.