Instance Learning PHP FastTemplate Template
If you have never touched PHP, then look at this first, of course, even if you have already understood the PHP, a PHP4 manual is still needed, :). In addition, a HTML syntax manual is of course an indispensable. . . . . . . . . . Do you often face the distress of the revision in the development process? Hundreds of thousands of documents are required for all the small changes on the layout, is it unpredictable? Hey, if you can separate the content and expressions, this is always waiting. But unfortunately, XML used to deal with this problem is not completely mature. Is there any way? As the so-called thing is dead, people are alive, and the PHP library we have to learn today can help us to deal with this issue to a certain extent. :)) What is fastTemplate? From the PHP language, it is a PHP library; from its origin, it comes from a PERL package that is the same name; it is a utility that allows you to change the entire site appearance in a few seconds. In the most popular language, it is a template, a template similar to Dreamwaver. Now fastTemplate is a question mark in your heart? Still an exclamation point? Or is it a period? (Editor: Rely, in this deceive fee, I am flat!) Forget, no matter how much, you just know that he is a good thing, :) First before we use this library, you must download it first, everyone can Below this website http://www.thewebmasters.net/php/ Download it (this site download address is: http://www.phpe.net/downloads/1.shtml).
After downloading it, remove it into a directory of your web server, below is the decompressed directory structure fastTemplate-1.1.0 / fasttemplate-1.1.0 / readme <- This file doesn't have to say it? FastTemplate-1.1.0 / class.fastTemplate.php3 <- This file is most important, it is in the library file, the core Lord! FastTemplate-1.1.0 / example_1.phtml <- an example fastTemplate-1.1.0 / example_2.phtml <- second example fasttemplate-1.1.0 / example_3.phtml <- third example fasttemplate-1.1.0 / dynamic_example .phtml <- Fourth Example FastTemplate-1.1.0 / DOCS / <- Document Directory FastTemplate-1.1.0 / DOCS / FASTTEMPLATE.3 <- UNIX Man Page FastTemplate-1.1.0 / DOCS / FASTTEMPLATE.HTML <- HTML Documentation fastTemplate-1.1.0 / templates / <- TabletTemplate-1.1.0 / templates / principal-1.1.0 / templates / main.tpl fastTemplate-1.1.0 / templates / header.tpl fastTemplate-1.1.0 / templates / main.tpl fasttemplate- 1.1.0 / templates / row.tpl fasttemplate-1.1.0 / templates / test.tpl fastTemplate-1.1.0 / templates / footer.tpl fasttemplate-1.1.0 / templates / htaccess.tpl fasttemplate-1.1.0 / templates / Middle.tpl fastTemplate-1.1.0 / templates / table.tpl pay attention to, this directory must be the directory of PHP programs to access 哟, in other words, the include directory in php.ini. Then, friends who have been programmed with PHP4 are noticed, you can't use this library directly, you still need to make some modifications! Pay attention to the following. PHP3 readers don't have to manage so much, you can try the examples it belt now, (嘿, but, it's the suffix name of those examples is PHTML, if you can't set the web. You can try Conversion to the suffix name, it should also be used, and there is no tried dare to make the ticket.
)that! Then, the brothers of PHP4 should pay attention to 哟, if you don't press the following modified words, this library has no way to use! ! --- Class.fastTemplate.php3 Sun Jun 27 13:44:47 1999 php4.fastTemplate.php3 Tue Jul 20 10:49:25 1999 @@ -196, 8 196, 10 @@ settype ($ VAL , "String");} - $ TEMPLATE = EREG_REPLACE ("{$ Key}", "$ VAL", "$ Template"); - // $ Template = STR_REPLACE ("{$ key}", "$ val" "$ Template"); // php4 doesn't like '{$' Combinations. $ key = '{'. "$ key". '}'; $ template = EREG_REPLACE ("$ key", " $ VAL, "$ Template"); / $ template = STR_REPLACE ("$ key", "$ val", "$ template");}} @@ -410, 7 412 ,7 @@} IF ($ END) {- $ newparent. = "{$ macroname}"; $ newparent. = '{'. "$ macroname}";} // next line please if ($ end) {$ END = false;} Everyone uses the text editor to open the class.fastTemplate.php3 file, find the above part. '-' minus the representative to eliminate this line, the ' ' plus sign representative to join this line. In addition, friends under the Windows system should pay attention! You also need to change some small things, change the value of the $ Win32 variable below to True, don't change, you can't use it, don't marry me,;). Var $ Win32 = true; // set to true if this is a win32 server, you can try his examples. how is it? Successful.嘿嘿 嘿 ~~~, hidden will not lie to everyone. OK, now this library is already available, we are ready to do the following, :) How to use this library? Simple, first put this library into in.
That is to say, want to include "class.fastTemplate.php3"; then? Oh ... then I don't know! (Editor: "Hey! Looking for Flat, you!"), Ah ...! Sorry, I remembered (after the hiding of the house, the sea is edited). Then learn the principle of using this library. Here, let us first make a hypothesis. We assume that a page consists of many small parts (such as: each site has a column navigation, etc.), and each small part has a unique identifier (for example: we put the column. Item Definition as a name) We first take this library as an example, let everyone learn the basic usage of this library as soon as possible, but everyone should pay attention to 哟, these documents are in the server position to press If you decompress the relative path, don't forget, just like you don't forget your girlfriend.
Ha ha ~~~~ // Example FastTemplate Demo # 1 - The Example from the man page header ("CLASS.FASTTEMPLATE.PHP3); $ TPL = New FastTemplate ("./Templates"); $ TPL-> Define (Array (main => "main.tpl", table => "Table.tpl", row => "row.tpl")); $ TPL-> Assign (Array (Title => "FastTemplate Test")); for ($ n = 1; $ n <= 3; $ n ) {$ Number = $ N; $ Bignum = $ N * 10; $ TPL-> Assign Array (Number => $ Number, Big_Number => $ BIGNUM); $ TPL-> Parse (Rows, "Row");} $ TPL-> PARSE (Main, Array ("Table", "Main")) $ TPL-> fastprint (); exit;?>