HTML code and no PHP code. The PHP code is all saved to a separate file, which is the file that is actually called by the page URL. The Web server parses the file through the PHP engine and returns the results to the browser. In general, PHP code always dynamically generates page content, such as querying a database or performing some sort of calculation. Here is an example:
example.php
Require (' class. Fasttemplate.php ');
$TPL = new Fasttemplate
URL. The Web server parses the file through the PHP engine and returns the results to the browser. In general, PHP code always dynamically generates page content, such as querying a database or performing some sort of calculation. Here is an example:Copy CodeThe code is as follows:example.phpRequire (' class. Fasttemplate.php ');$TPL = new Fasttemplate ('. ');$TPL->define (' main ' = ' main.htm ',' Header
placeholder. The main advantage of using a template is that the interface designer can edit these files as needed, such as setting fonts, changing colors and graphics, or completely changing the page layout. The interface designer can use any common HTML editor or visualization tool to edit these pages, because these files only contain HTML code, without any PHP code.All PHP code is saved to a separate file. This file is actually called by the page URL. The Web server parses the file through th
server parses the file through the PHP engine and returns the result to the browser. In general, PHP code always dynamically generates page content, such as querying a database or executing a computing task. The following is an example:// Example. phpRequire ('class. FastTemplate. php ');$ Tpl = new FastTemplate ('.');$ Tpl-> define (array ('main' => 'main.htm ','Head' => 'header.htm ','Leftnav' => 'leftna
page. Interface designers can edit these pages with any normal HTML editor or Visual tool, because they contain only HTML code and no PHP code.
The PHP code is saved in a separate file, which is the file that is actually called by the page URL. The Web server parses the file through the PHP engine and returns the results to the browser. Generally, PHP code always dynamically generates page content, such as querying a database or performing some sort of calculation. Here is an example:
Co
actually called by the page URL. The Web server parses the file through the PHP engine and returns the results to the browser. Generally, PHP code always dynamically generates page content, such as querying a database or performing some sort of calculation. Here is an example:
example.php
Require (' class. Fasttemplate.php ');
$TPL = new Fasttemplate ('. ');
$TPL->define Array (' main ' => ' main.htm '),
(fasttemplate), the problem now is how to implement similar functions in ASP.
Microsoft's ASP comes with two kinds of scripts: VBScript and JScript. They all carry a "regular Expression object" (REGEXP) that makes it easy to implement template functionality with string objects and RegExp objects. Mu Maple to write a "Template.JScript.INC" file, the contents of this file attached to the post. The ability of the reader can be based on their own needs to improve.
Here's how to use this. Because th
template program (fasttemplate), the problem now is how to implement similar functions in ASP.
Microsoft's ASP comes with two kinds of scripts: VBScript and JScript. They all carry a "regular Expression object" (REGEXP) that makes it easy to implement template functionality with string objects and RegExp objects. Mu Maple to write a "Template.JScript.INC" file, the contents of this file attached to the post. The ability of the reader can be based on their own needs to improve.
Here's how to us
: There is no way to automatically convert an integer to a binary representation in Python with a percent-semicolon formatExampleTPL ="I am%s"%"Alex"Print(TPL)-I am alextpl="I am%s age%d"% ("Alex", 18)Print(TPL)-I am Alex age 18TPL="I am% (name) s age percent (age) D"% {"name":"Alex"," Age": 18}Print(TPL)-I am Alex age 18TPL="percent%.2f"% 99.97623Print(
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 the template.
First, set the init. inc. php file as the initialization configuration file of the Smarty template.
Init. inc. php
Define ('root _ path', dirname (_ FILE _); // defines the website ROOT directory
Require ROOT_PATH. '/libs/Smarty. class. ph
Use Smarty in PHP: use of variables. All the accesses to Smarty are variable-based. The following describes how to use an instance. Example: the main file introduces the template to initialize the configuration file (init. inc. php) and a class. all access to Smarty is based on variables. 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 the templat
? Simple, first of all, to include this library. In other words, to include "class." Fasttemplate.php3 "; And then? Oh...... Then I don't know! (Editor: "Hey!") Look for a flat, you! "Ah, ah ...! Sorry, I think of it (after the Tibetan people edited the sea flat after a meal). Then learn how to use the library. Here, let's make a hypothesis.
Let's assume that a page is made up of a lot of small parts (for example: Every site has a column navigation, and so on), and each small part has a unique
/**** By fallen moon shadow * Please mail me when you find errors!*/// Contains common database operations// Include 'db. Class. php ';// Contains the smarty database operation class library// Include "Smarty/libs/smarty. Class. php ";// Of course, it can also be included in the parent directory//-----------------------------------------------------------Class pagesmarty {// Class InputVaR $ db; // The parameter is passed in for database operationsVaR $ TPL
formatting: tpl = "I am % s" % "nick" tpl = "I am % s age % d" % ("nick", 18) tpl = "I am % (name) s age % (age) d" % {"name": "nick", "age": 18} tpl = "percent %. 2f "% 99.97623 tpl =" I am % (pp ). 2f "% {" pp ": 123.425556,} tpl
$TPL =new Smarty ();//Create a new Smarty object, I use the
Smarty-3.1.6Version
1. Set the Smarty template path $tpl->
Settemplatedir (); By default
templates2. Set the Smarty template compilation path $tpl->
Setcompiledir (); By default
Templates_c3. Set the left and right separators of the Smarty template engine,
$tpl
format them to the specified position (uppercase E)
F. Convert integers and floating-point numbers to floating-point numbers and format them to the specified position (the default value is 6 digits after the decimal point)
F, same as above
G. It is automatically adjusted to convert integers and floating-point numbers into floating-point or scientific notation (more than 6 digits are counted in scientific Notation ), format it to the specified position (e for scientific counting ;)
G. It is
specified position (uppercase E)
F, converts an integer, floating-point number to a floating-point number representation, and formats it to a specified position (the default is 6 digits after the decimal point)
F, ibid.
G, auto-adjust convert integers, floating-point numbers to floating-point or scientific notation (more than 6 digits in scientific notation), and format them to a specified location (if scientific counts are e;)
G, auto-adjust convert integers, floati
languages, after learning one language, you can easily master other languages. The main reason for using the template engine is to separate front-end engineers from backend engineers. Therefore, the template engine is not only used by backend engineers, but also by front-end engineers.
1. use of the template engine by backend engineers
The PHP script contains the file where the template engine class is located. As follows:
Require ("mytpl. class. php"); // contains the template engine class, wh
Please help me to use the smarty template by checking Warning: Smartyerror: unabletoreadresource: This post was last edited by tiancai784071179 from 2015-05-2115:08:47: I checked it with $ tpl- gt; template_dir, the template directory is correct. why do you want to help use the smarty template? Warning: Smarty error: unable to read resource:
This post was last edited by tiancai784071179 at 15:08:47Template directory: I used $
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.