Home  >  Article  >  Backend Development  >  php Smarty First Experience 2 Obtaining Configuration Information_PHP Tutorial

php Smarty First Experience 2 Obtaining Configuration Information_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:25:58689browse

Let’s look at the results first——

The page source code is as follows:

Analyze the code. After checking the index_config.php (Smarty connection file) and index.php files, there are no errors. Let’s focus on the template file. The possible reason lies in this tpl file. Here is the code——

Copy code The code is as follows:

{% config_load file="1.conf" section="style2" %}
< ;html>


{% # title# %}

{%$hello%}
{%*This is A comment statement *%}


{%$array.0.0%}



Smarty cannot parse the variables in the template file into corresponding values. It must be an error when calling the file, but the code written is correct. It is almost exactly the same as the one in the book and on the Internet. How could it go wrong? ? ?

When I was puzzled, I suddenly discovered that my code had more spaces than theirs when calling variables………………

Delete the spaces and you’re done:

Page source code

In summary, when using Smarty templates, do not add spaces for the sake of code beauty and readability. In this way, Smarty will not parse these as variables, but will directly output

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324019.htmlTechArticleLook at the results first - the page source code is as follows: Analyze the code and check index_config.php (Smarty connection file) , index.php files are all correct, let’s focus on the template file, you can...
Statement:
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