Implement HTML and PHP code separation using the IntegratedTemplate class in PHP4
People who use PHP programming will encounter such a problem: When the PHP code is together, see the PHP code is very hard, and the entire file cannot be edited by Dreamweaver, which is called this for PHP programmers and the art. The file is like a nightmare. Template technology in PHP is to solve this problem. There are a lot of PHP templates, and FastTemplate and phplib are more common, because the appearance of the PHP programming world is very large. PHP programmer does not know these two classes, just like the VB programmer does not know the MSGBOX function, is an incredible thing. We need to download the PHP template class before, now PHP4 has its own template IntegratedTemplate and IntegratedTemplateExtension, features and phplib. These two classes are the relationship between subclass and parent class. Generally we can use IntegratedTemplateExtension. What is incredible is that IntegratedTemplate is not inherited from the PEAR class and cannot use the PEAR class's debug function. The following example shows their usage, assuming the IntegratedTemplate class and the IntegratedTemplateExtension class are in c: / php4/pear/html/itx.php and c: / php4/pear/html/itx.php. The code we wrote is placed in c: /testphp/php4/welcome.htm and c: /testphp/html/welcome.php. Set C: / TestphP / PHP4 to virtual directory / testphp on Web Server and give the script permissions, confirm that c: /tephp/html/welcome.htm cannot be accessed via remote browser. In PHP.INI, set include_path = ".; C: / PHP4 / PEAR" Example 1: We placed the tag of the variable in the HTML file, set the value of the variable with the PHP code, then replace the tag in the HTML, final output Go to the customer browser.
The following is a Welcome.htm code, we put three PHP TAG (variable tags): {welcome}, {welcomeMessage}