PHP template engine

Source: Internet
Author: User
PHP template engine PHP development programs are usually mixed with php code and html. so what's the problem?

First, it is not conducive to division of labor and cooperation. Generally, programmers write code to design the webpage by the artist. In this way, the programmer must wait for the artist to design the interface to start working. That is to say, the work of programmers and artists cannot be synchronized.

Second, it is not conducive to maintenance and has poor maintainability. For example, to modify the interface after the program is fixed, the programmer must modify the interface and then add it again.

Finally, the program structure is messy and the readability is poor. HTML and PHP are mixed together, and once there are more than one program, it will become very messy.

The template technology emerged to solve these problems. to solve these problems, the first thing that emerged was the template technology using php labels.

1. interpreted PHPLIB
(1) procedures

$ T = new Template ()
$ T-> set_file
$ T-> set_var
$ T-> parse
$ T-> p

Translate to Chinese

Initialize template class $ t set template file set template variable analysis template file template variable output content

At least five steps are passed to implement template processing in the php program.

(2) processing loop nesting:


{It}

2. Compile-type Smarty program processing process
(1) procedures:

$ S = new Smarty
$ S-> assign
$ S-> display

Translate to Chinese

Initialize template class settings template variable parsing and output Template

(2) processing loop nesting:

<{Section name = loopName loop = $ loopArray}> (for example, foreach)

Summary:

PHP does not require a very proficient syntax. PHP does not require you to develop many libraries on your own. PHP does not require you to worry about the features of languages such as performance and stability.

What PHP needs is your logic; what PHP needs is your creativity; what PHP needs is your thoughts !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.