In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "smarty template engine how to get data from the configuration file", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "smarty template engine how to get data from the configuration file" bar!
When the value of a variable does not want to be written dead in the program, you can write the variable to the configuration file and get it from it (common configuration styles).
The first step: first write a configuration file, such as the db.conf of the database, with the suffix conf as you like, or db.ini. The format of the content in the file needs to be fixed: key= "value". There is no need to add a semicolon or anything after each line. Go straight back to China and change the line, such as:
Configuration file: db.conf
The copy code is as follows:
Host = "localhost"
Username = "root"
Password = "123456"
Db_name = "liuyan"
Template file: temp.tpl
Use {config_load file= "db.conf"} to bring the file in. Note that if you write a relative path, look at it in terms of the page you visit. For example, here, temp.tpl is placed in the templates directory, and db.conf is placed on the same layer as the templates directory, but since the browser accesses the file index.php at the same level as db.conf, when referencing, write {config_load file= "db.conf"} directly.
The copy code is as follows:
{config_load file= "db.conf"}
Smarty variable operation, obtained from the configuration file
{# host#}
{# username#}
Browser access: index.php
Unlike getting variable data from php, you don't need to assign it with assign, but load it directly in the template file.
The copy code is as follows:
Thank you for reading, the above is the content of "smarty template engine how to get data from the configuration file", after the study of this article, I believe you have a deeper understanding of how the smarty template engine obtains data from the configuration file, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.