To make it easier to use smarty, we can put the three steps "loading the Smarty template engine", "Creating a Smarty object", and "setting the parameters of a Smarty object" in a public PHP file, in the future, we can reuqire it directly, for
Smarty is a template engine written in PHP and one of the most famous PHP template engines in the industry. It separates the logic code from the external content and provides an easy-to-manage and use method to combine the originally HTML code with
All the accesses to Smarty are variable-based. The following describes how to use an instance.
Example: The main file introduces the template Initialization Configuration File (init. inc. php) and a class, and assigns values to the variables in
There are many text processing functions in PHP. You can use the function to process the text to be processed, and then call assign () in the Smarty template engine to assign values to the variable, assigned to the template for display.
The
Define ('base _ path', $ _ SERVER ['document _ root']);Define ('smarty _ path', '\ smartTest \ SMARTY \\');Require BASE_PATH.SMARTY_PATH. 'smarty. class. php ';/* This path of $ dir2 is displayed on the presentation page. The strings below are the
This method is triggered when the PHP engine encounters a class that is not instantiated. of course, you need to use _ autoload () in your php code. Below is a section using _ autoload () for your reference:
The code is as follows:
/***
This article mainly introduces how the smarty template engine uses the built-in function foreach to retrieve all array values in a loop. The example analyzes several common techniques of foreach looping arrays, for more information about how to use
This article mainly introduces how the smarty template engine obtains data from php, involves the mixed coding techniques of smarty variables and php code, and has some reference value, for more information about how to obtain data from php, see the
Php provides a detailed method and implementation code for generating static pages. Fread () and fwirte () are used in php (). After a static page is generated, the modification will be involved. Here, we can use the regular expression matching
This article is the third article on improvement of the PHP + jQuery registration module. it mainly records the update of Smarty to the latest version 3.1. it is a very useful article. if you need it, refer to jQuery.
Smarty3.1X (the latest
What is cache! What can we do! In fact, the cache is equivalent to memory. Save for a while! Cache means that we do not need to execute the database when executing something. It is okay to directly execute our Cache. In general, the purpose of the
Something written in PHP. Some small things may be useful sometimes! 1. obtain the client IP address functiongetip () {if (! Empty ($ _ SERVER [HTTP_X_FORWARDED_FOR]) {proxy usage $ tipsplit (, $ _ SERVER [HTT some things may be useful sometimes!
1
This article describes how to use variables in the PHP template engine Smarty. it describes in detail the principles of the Smarty template, downloading, configuration methods, and usage of variables, for more information about how to use variables
Install and configure Smarty. Download the latest Smarty: smarty.php.net latest version: 2.6.18 unzip the libs directory in the directory to smarty, copy to your site directory, while downloading the latest Smarty: http://smarty.php.net/
Latest
The usage of Smarty-related considerations and several ways to share access variables, you can refer to the need of friends. $ Tpl = new Smarty (); // create a new smarty object. what I use is
Smarty-1, 3.1.6Version
1. set the path to the smarty
This article mainly introduces the post usage in smarty, and analyzes in detail the implementation process of POST in smarty in the form of instances, including the call of the configuration file and the implementation of the template file, for more
In the environment on the server, smarty reports the following error: Warning: Smarty: include (C: \ Inetpub \ wwwroot // compile/\ % EB ^ EBD ^ EBDB4A85 % login. tpl. php) [smarty. include]: failed to open stream: No such file or directory in C: \
Why does PHP Cache technology need to be used? The reason is simple: improve efficiency. In program development, the primary way to obtain information is to query the database. In addition, it may also be through Web Services or some other method.
After some exploration, I finally found a method and wrote it out for you to give pointers: first in smartt. class. in php, add the following method to the Smarty class: PHP code: parameter 1: html file storage path, parameter 2: written content
PHP and Smarty generate EXCEL document 1. First, generate a template in EXCEL (office2003) and save it as an xml table. 2. Modify the xml file to form a smarty template. 3. Then, bind the variable and output it. However, according to my test, if you
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.