Talk about the template selection in PHP program development

Source: Internet
Author: User
Tags mixed pear php class php and
The template for PHP is really a tricky thing to say. A random number of about 20 or more options, light pear contains 5 of different templates, it is really a headache.

Do not say that the good one, choose a template before the best to figure out what the real purpose of the template? Simply put, the core purpose of the template is a team work. There are two main modes of action:

1. Separating HTML and PHP makes it much more enjoyable for web designers and PHP programmers to collaborate.

2, the separation of display logic and the logic of things, so that the core transaction logic changes and application expansion is easier and more flexible, which means that the cooperation between programmers more enjoyable. (This is often overlooked or misunderstood, always think that the PHP out of the HTML is called separate display logic and logic of things, if so why did you let PHP and HTML mixed together? )

Figuring out what the real purpose of the template is, it's easy to make the right choice.

If you're the only PHP programmer who needs to work with other web designers, choose a template that separates HTML from PHP, Phplib (now seems to be integrated into Pear http://pear.php.net/package/ Html_template_phplib) or

Fasttemplate is such a thing, very simple easy to start.

If your website interface is ugly and mostly done by programmers, but the function is more complex and need powerful extension function, need to separate various levels including display logic, then do not use anything special, PHP itself is the best template. Note that in this case, you want to design your program very carefully, always remember to detach not PHP and HTML but transaction logic (business logic) and display logic (presentation logic). That's why I've always been very resistant to Smarty, because the Smarty syntax is so complex and powerful that it's almost reinventing a scripting language thing (even PHP programmers have to learn it again). More puzzling is that the more powerful the script, the easier it is to have the transaction logic (business logic) and display logic (presentation logic) mixed together, destroying the original intention of the template.

If you want to separate HTML from PHP, get a better visual design, and think that the entire system has a very powerful scalability to adapt to HTML,XML,WML interfaces, and that you don't have to learn complex syntax to provide high operational efficiencies, then this is a fairly challenging issue. The bad news is that there is no mature template to really achieve this requirement, the good news is that it is not difficult to complete such a template, if you have tried Zope or ColdFusion will find this template shadow,

(Wact http://wact.sourceforge.net/and Phptal http://phptal.sourceforge.net/are in this direction, should be very promising).

There are two main ways to combine template and data (template invocation): Push and pull way.

The push is to use PHP to push data to the template, which means that programmers need to explicitly assign values to each variable in the template and tie them up.

And pull the way like the PHP and HTML mixed together, template species of variables to take the initiative to drag data in.

When it comes to templates, there are two other things to mention:

Phphtmllib and Quickform (http://pear.php.net/package/HTML_QuickForm) are the traditional ways to complete HTML pages through a variety of page artifacts The entire structure of the page is fully mastered by programmers, and perhaps many programmers who have written traditional GUI desktop programs prefer this approach.

A more beautiful scheme

If you do business software, Flash should be a more beautiful solution (don't be mistaken, don't think you know that PHP supports the Ming and SWF libraries can dynamically generate Flash, which is not what I'm talking about.) I want to say is the support flash Remoting, this kind of thing is really meaningful PHP and flash combination. The Flash section is completed by the visual designer, and the PHP programmer sends the data to the Flash client via Flash remoting.

There are currently two options:

amfphp

http://www.amfphp.org/

Because the Macromedia Flash Remoting transmits data using a unique and more efficient data format, amfphp constructs the corresponding PHP class on the server side to receive it by analyzing the data format. Parsing and encoding the data to achieve the function of exchanging information (like Samba, it should belong to a Hacking bar).

Phpobject

http://ghostwire.com/resources/phpobject/

Phpobject uses an alternative method of transmitting data through open format soap by embedding some ActionScript components in Flash.

In fact, the template on PHP is also involved in a lot of other issues, 1:30 I can only write so much.



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.