This article mainly introduces the simple php smarty Getting Started program. The example analyzes the configuration and usage skills of the smarty template. if you need it, you can refer to the example below to describe the simple php smarty
php-smarty-Cache 2 (26), phpsmarty-cache
A page, some data cache, some data is not cached, is the local cache
L $smarty->assign ("var", "value", true)
Third parameter: Indicates whether to not cache
L {$var Nocache=true}
Use the NoCache
Php-smarty-3 (), phpsmarty-320
First, comments
* Note content *
HTML comments are displayed in the client source file
Smarty comments are not sent to the client
Smarty's comments are mainly for the template designer to see
Second, the variables
Php-Smarty-1 (18), phpsmarty-118
Smarty
I. template principles
1. Why use a template?
1) scenario:
For ($ I = 0; $ I
Echo ''. $ row ['proname']. '
}
The above code is used to mix html and php, which is not conducive to development and maintenance.
2
I begged for the PHP + SMARTY three-level classification method. Online waiting for a rush to seek PHP + SMARTY three-level classification methods are all given. Online and other urgent
Three levels of foreach can be used to loop three levels of
Environment: PHP5.2 or laterGo to the official website to download the Smarty Template engine library file to your computer or serverSmarty Official Website library files: https://www.smarty.net/downloadUnzip to local after download is
The example of this article tells the PHP Smarty template simple use method. Share to everyone for your reference, specific as follows:
index.php:
Require ('.. /libs/smarty.class.php ');
$smarty = new Smarty;
Add custom
The variable operator of the php template engine smarty can be used to operate variables, user-defined functions, and characters. The variable operator of the php template engine smarty can be used to operate variables, user-defined functions, and
The variable operator of the PHP template engine smarty can be used to operate variables, user-defined functions, and characters.The syntax uses "|" to apply the variable operator. for multiple parameters, use ":"?? Refers to memory? /Div>Capitalize
1. Smarty cache Configuration:$ Smarty-> cache-dir = "directory name"; // create a cache directory name$ Smarty-> caching = true; // enable cache. If it is false, the cache is invalid.$ Smarty-> cache_lifetime = 60; // cache time, in seconds2. Use
Welcome to the Linux community forum and interact with 2 million technical staff. Go to php's smarty simple installation configuration Introduction: 1 first, download: 2 and then install: (1) unzip the file, copy the libs file to the root directory
This article explains the simple use of PHP smarty templates. Share to everyone for your reference, as follows:
index.php:
Require ('.. /libs/smarty.class.php '); $smarty = new smarty;//Add a custom adjuster $smarty->registerplugin ("modifier",
Php-Smarty-Cache 2 (26), phpsmarty-Cache 26
On a page, some data is cached, and some data is not cached, that is, local cache.
L $ smarty-> assign ("var", "value", true)
Third parameter: indicates whether the cache is not cached
L {$ var nocache
Php-Smarty-6 (23), phpsmarty-623
Next
10. html_options prints a set of options for select elements.
{Html_options values = $ cust_ids selected = $ customer_id output = $ cust_names}
text
Values: array of Values
Output: Text Array
Selected: the
Third, the method
L Assign: assigning variables to templates
L ASSIGNBYREF: Assigning variables to templates (passed by reference)
L Append: Append template variable to an array
L appendbyref: Append template variable to an array (passed by
First, the principle of caching:
IE: Saving a resource file to a local
Smarty: Saving the cache to the server
Compile
Second, why the use of caching technology
1. Improve website access speed
2. Reduce Web server pressure
3, reduce the database
However, according to my experiment, if you do not delete a place, the generated document opened with Excel, will be error!
Delete all the strings like this: ss:expandedcolumncount= "5" on the line!
Example:
Fill in the data, then submit, generate
Configuration of the 1,smarty cache:
Copy the Code code as follows:
$smarty->cache-dir= "directory name"; Create a cache directory name$smarty->caching=true; Cache is turned on, false when caching is not valid$smarty->cache_lifetime=60; Cache time
Today comes a big and tricky question-after updating the Smarty template, the page is white, but in the pre-release environment, there's no such thing as a test! Finally, the reason is found to be related to the Smarty template compiling principle.
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.