Before explaining the use of PHP explanatory template phplib, let's explain why the template system using PHP tags continues to improve. In fact, this is mainly because the PHP tag is not convenient for artists. They prefer to use this visual label directly, such as {title}.
First of all, we have modified our previous example to use a visual label to handle it. The first step, change the shownews.php to Shownews.tpl, the inside of the PHP tag into a visual label, SHOWNEWS.TPL code as follows:
- < html>
- < head>
- < title> Show News < /title>
- < /head >
- < body>
- {title}
- < /body >
- < /html >
The second step, how to achieve the effect of listnews.php? Actually very simple, I just have to replace {title} to not be OK? So, the code for the modified listnews.php is as follows:
- < ?
- Include (' getnews.php ');
- Get Data
- Echo Str_replace (' {title} ',
- $news, file_get_contents
(' Shownews.tpl '))
- ?>
In fact, PHP explanatory template phplib principle is exactly the way! For example, we want to use Phplib to achieve the above function, we just need to modify listnews.php. The following code is modified:
- < ?
- Include (' getnews.php ');
- Get Data
- Include (' template.class.php ');
- $ T = New Template ();
- $t- > set_file (' Shownesw,
' Shownews.tpl ');
- $t- > Set_var (' News ', $news);
- $t- > Parse (' Out ', ' shownesw ');
- $t- > P (' out ');
- ?>
In addition to the PHP explanatory template phplib area, you can check the corresponding manual.
http://www.bkjia.com/PHPjc/446061.html www.bkjia.com true http://www.bkjia.com/PHPjc/446061.html techarticle before explaining the use of PHP explanatory template phplib, let's explain why the template system using PHP tags continues to improve. In fact, this is mainly because the PHP tag for artists ...