People who use PHP programming will encounter such a problem: when PHP code and HTML code are together, it is very difficult to read the PHP code, and the entire file cannot be edited with Dreamweaver. This is very difficult for PHP programmers and artists. , modifying such a file is a nightmare.
The template (Template) technology in PHP emerged to solve this problem. There are many PHP template classes, the more common ones are FastTemplate and PHPLib. Because they appeared early, they are very famous in the PHP programming world. PHP programmers do not know these two classes, just like VB programmers do not know the MsgBox function, it is an incredible thing.
In the past we needed to download PHP template classes, but now PHP4 has its own template classes IntegratedTemplate and IntegratedTemplateExtension, which have similar functions to PHPLib. These two classes are related to subclasses and parent classes. Generally we can use IntegratedTemplateExtension. What is incredible is that IntegratedTemplate does not inherit from the PEAR class and cannot use the debug function of the PEAR class.
The following examples illustrate their usage, assuming that the IntegratedTemplate class and IntegratedTemplateExtension class are in C:php4pearHTMLITX.php and C:php4pearHTMLITX.php respectively. The code we wrote is placed in C:TestPHPPHP4Welcome.htm and C:TestPHPHHTMLWelcome.php. Set C:TestPHPHPPHP4 to the virtual directory /testphp on the Web Server and grant script execution permission. Make sure that C:TestPHPHHTMLWelcome.htm cannot be accessed through the remote browser. Set include_path = ".;C:php4pear"
in php.ini Example 1:
We place variable tags in the HTML file, set the variable value with PHP code, and then replace the tags in the HTML , and finally output to the client browser.
The following is the Welcome.htm code. We have placed three PHP tags (variable tags): {WelcomeTitle}, {UserName}, {WelcomeMessage}