Directory, put Smarty. class. php,
Copy the Smarty_Compiler.class.php, Config_File.class.php, and debug. tpl files to the dataobjects directory.
You also need to copy the core and plugins directories and all the contents. create several new directories named templates, templates_c, configs,
And cache.
Finally, the dataobjects directory contains:
| ---- Cache| ---- Configs| ---- Core| ---- Plugins| ---- Templates| ---- Templates_c
11/10/2004 11: 17 a.
For more information about PHP's Smarty learning, see the documents on the network. you can use Smarty to perform a simple test:
1. decompress the Smarty file to the website directory, such as libs.
2. create the templates, templates_c, configs, and cache directories.
3. create a test page: index. php
Require "main. php ";
// $ Tpl defined in main. php
$ Tpl-> assign ("title", "webpage title for te
PHP template engine Smarty built-in variable mediation usage details, template smarty. The usage of the PHP template engine Smarty built-in variable mediation is described in detail. the template smarty this article describes the usage of the PHP template engine Smarty built-in variable mediation. For your reference, see the usage of the built-in variable mediation tool Smarty of the PHP template engine and the template smarty.
This article describes the usage of the PHP template engine Smarty
PHP Template engine technology simple implementation, PHP template engine
After using the SMARTY,TP, but also want to understand how its template technology is implemented, so write a simple template class, basically read the template file-and Replace template file content, save or static
tpl.class.php Main Analysis
Assign method implementation
/* * Template Assignment Operation * @param mixed $TPL _var If it is a string, i
Refer to the data on the network, using Smarty can be easily tested:
1. Unzip the Smarty to the site directory, such as the name Libs.
2. Create a Templates,templates_c,configs,cache directory
3. Build test page: index.php
Require "main.php";
$tpl defined in main.php
$tpl->assign ("title", "page title for Testing");$tpl->assign ("content", "contents of
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 example: 1. create a main. php ltSyntaxHighl
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,
/smarty/cache ';// $ Global ['smarty '] ['compile _ check'] = true;// Set the smarty error to disable$ Global ['smarty '] ['destgging'] = false;// Disable Cache$ Global ['smarty '] ['caching'] = false;// $ Global ['smarty '] ['cache _ lifetime'] = 6000;// Define the left and right boundary Operators$ Global ['smarty '] ['left _ delimiter'] = '$ Global ['smarty '] ['right _ delimiter'] = '}> ';?>[/Php][Php]/** Author: Boss Hui* Page: common. cfg. php* Function: global configuration* All Rights Re
I recently used the onethink officially published by thinkphp to set up the management backend. Because the company's previous code was written by smarty and there were more than 2000 templates, I was too lazy to use the think template engine to change them,Therefore, the smarty template engine is integrated and compatible with think templates.I. Add Application/Common/Conf/config. php'Tmpl _ ENGINE_TYPE '=> 'smarty ',II. Download the smarty template engineHttp://pan.baidu.co
/mobile-webapp-develop-essential-knowledge.html
Second, the environment to build
First you need to build a thinkphp project that contains the TPM. You can download the TPM on the official website of thinkphp, or you can get it in GitHub. GitHub's address is:Https://github.com/liu21st/extend/tree/master/Extend/Tool/TPMIn the downloaded file, copy the files in the TPL directory to your project folder under the TPL
as follows:
To include TMD_TPL in
Require '.. /tmdphp/tmd_tpl.php '; Please change to the path where you TMD_TPL
Instantiation of TMD_TPL
$TPL = new Tmd_tpl ();
Here is the configuration Tmd_tpl
Specifies the template directory, ending with a slash
$TPL->tpl_dir = './tpl/';
Specify template file name extension
It is recommended to use PH
Copy Code code as follows:
Class Lightpage_template {
var $Tpl _header;
var $Tpl _footer;
var $Tpl _parsing;
var $Tpl _template;
var $Tpl _dirname;
var $Tpl _parse_string;
var $
User Original PHP template class
the following is the PHP source code:Class Lightpage_template {var $Tpl _header;var $Tpl _footer;var $Tpl _parsing;var $Tpl _template;var $Tpl _dirname;var $Tpl _parse_string;var $
to register members (2). avi151.[php second quarter] the 22nd chapter uses OOP to register members (3). avi152.[php second quarter] the 22nd chapter uses OOP to register members (4). avi153.[php second quarter] The 23rd chapter uses the mysqli operation database (1). avi154.[php second quarter] The 23rd chapter uses the mysqli operation database (2). avi155.[php second quarter] The 23rd chapter uses the mysqli operation database (3). avi156.[php second quarter] The 23rd chapter uses the mysqli
replacement variable to the compiled file through File_put_contents ()
You can output compiled files by bringing in the compiled file include
function Con_replace ($content) is used to replace a variable in a template file (INDEX.DWT), and the variable value in PHP is assigned to a variable in the template to match the contents of the template file with a regular expression that matches the
Match to content and return the replaced content
The code is as follows
Copy Code
talk about the template.inc in Phplib. If you use a template to generate a static web page.
One, modify Template.incAdd a few of the following functions:Save the analysis results to a filefunction SaveToFile ($dir, $varname) {$data = $this->finish ($this->get_var ($varname));$FP =fopen ($dir, "w+");Fwrite ($fp, $data);}Clearing an array of assigned valuesfunction Renew () {$this->varkeys=array ();$this->varvals=array ();$this->file=array ();}
The first function is to save the results to a stati
programs
*
* Author: Master
* Email: teacherli@163.com
*
**************************************** *****/
Include_once ("./comm/Smarty. class. php"); // contains the smarty class file
$ Smarty = new Smarty (); // Create a smarty instance object $ smarty
$ Smarty-> templates ("./templates"); // you can specify the Template directory.
$ Smarty-> templates_c ("./templates_c"); // you can specify the compiling directory.
// *** NOTE: I am a new *** here ****//
$ Smarty-> cache ("./cache"); // you
.com***************************************** *****/Include_once ("./comm/Smarty. class. php"); // contains the smarty class file$ Smarty = new Smarty (); // Create a smarty instance object $ smarty$ Smarty-> templates ("./templates"); // you can specify the Template directory.$ Smarty-> templates_c ("./templates_c"); // you can specify the compiling directory.// *** NOTE: I am a new *** here ****//$ Smarty-> cache ("./cache"); // you can specify a cache directory.$ Smarty-> cache_lifetime = 60*
, the parent class will continue to be looked up. However, if a subclass defines a class property that has the same name as the parent class, the class property of the child class hides the class property of the parent class.
See an example:
Class A (object): count = 1 class B (a): Pass class C (a): pass print A.count, B.count, C.count B.count = 2print a.count, b.count, C.count A.count = 3print A.count, b.count, c.count print B.dictprint c.dict
As a r
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.