Implementing the BLOCK function using the IntegratedTemplate class in PHP4_PHP Tutorial

WBOY
Release: 2016-07-13 16:57:58
Original
911 people have browsed it

Using PHP template classes for programming is very beneficial, but sometimes you will encounter a problem, such as outputting a table, but the number of rows in the table will not be known until it is run, such as message boards, BBS, shopping websites, etc., often Encountered this problem. At this time, the artist cannot decide how many tables to use in the HTML file. If the loop output is written in the PHP code file, it will be inconvenient for the artist and PHP programmers to read the code. The artist will say, the table here Where did it go? What should I do if I want to change the color background of the table? PHP programmers will also say, why is there suddenly a , here, what is it for? Where will it be embedded in the HTML file? .
Programming using PHP template classes generally treats this uncertain number of HTML elements as a "block". Programming bolck is similar to writing a loop in the code. This function is available in the more commonly used PHP template classes (such as FastTemplate and PHPLib). Writing nested blocks is similar to writing multiple loops. Now let's take an example to illustrate the programming method of block in the IntegratedTemplateExtension class in PHP4. In the example, a double loop is used, the outer block is GoodsList, and the inner block is GoodsListOfSomeType.
Basic setup: Assume that the code we write is placed in C:TestPHPPHP4GoodsList.htm and C:TestPHPHTMLGoodsList.php. Set C:TestPHPHPHP4 to the virtual directory /testphp on the Web Server and grant script execution permission. Make sure that C:TestPHPHHTMLGoodsList.htm cannot be accessed through the remote browser. Assume that PHP4 is installed in C:php4, set include_path = ".;C:php4pear" in php.ini
The following is the content of GoodsList.htm:


Item list in shopping bag