Summarize the advantages of PHP templates for you

Source: Internet
Author: User
Tags php template what php

However, if it is a news system or a content publishing system. in this way, it is very necessary to use the template technology. because they all have a common place, that is, there is a type of page that needs to use the same style of page design. depending on the actual situation, such as the traffic volume, project urgency, and programmer's proficiency in template technology, select the template technology that best suits the project .. this is the first choice."

"From the very beginning, I started to use php templates. I used smarty templates for introduction (officially supported, powerful). The longer I used it, I felt that PHP templates had many advantages. As long as the page display is involved, I will use the template to write the content. If I do not use the template to write the program, I always feel awkward. I think other phper will share the same feeling, because the original intention of the template design is to separate the code from the page for separate processing. After all, no one is willing to write code while processing the page ."

"Some people say that SMARTY is good, but some people say that SUPERTPL is better, and some people prefer PHPLIB. I think every template has its own advantages and its own advantages, the key is what your project needs and what is best to use!" There must be no error in using templates. PHPLIB was initially used. After using the template for a while, it was too simple. Every template change volume should be replaced by code, every time you reference a template, you also need to write a line of code (maybe PHPLIB has the batch processing function, I don't know about it), so I gave up. Later, when I used plog to build a site, I came into contact with smarty, it seems that smarty is too large to speed up the development process, but many functions are not actually used. Therefore, I wrote the template engine myself. The template implementation function is very simple, it is the replacement function of a template variable, plus the include other templates and the foreach block operation function."

"I still use PHPLIB, but I will write some functions or classes based on my own experience and needs to encapsulate some of the most commonly used processing for template output ." "I am tired of using my own template and writing template parsing code. I chose to use an existing good template ." I even saw some amazing people on other forums without using templates... maybe it's not that realm... I personally think it is better to use the template .. at least division of labor .. accelerate development. Use your own template? I don't feel it is necessary to use the ready-made functions. I just need to add some practical functions that I want to learn ." I don't use the template engine, but I also use the template, but it is different from yours. It is difficult to use the template engine because it is too slow ."

"I use a third party, preferably open source. ." I prefer to use my own template for simplicity and practicality ." "Considering the performance, I generally do not use general templates and will make some trade-off based on the actual situation, which has certain limitations ." Decide whether to use the template or what template to use as needed. There is always no harm in flexibility ." I personally like simple and quick templates. You can consider using ready-made templates. However, some functions that are not used in the templates are usually optimized based on the actual project ."

"The advantage of PHP templates is that they generally do not cause bottlenecks. The main factors that will affect the efficiency are as follows:

1. After the program and template are separated, one file will become two or more. Reading the template IO is also the key time.
2. parsing templates are relatively complicated. Generally, N functions such as preg_match and preg_replace are required to process or replace
3. The loading and replacement of the template obviously requires more memory than the template is not used.

To improve efficiency, pay attention to the following points:

1. The template parser supports compilation and caching. This is the most obvious benefit to the performance and depends on how you can flexibly apply it.
2. The parsing program should be as simple as possible. It is convenient to put all the functions into use, and the performance is poor.
3. html template pages follow simple principles, such as the xhtml standard. Try not to split a page into many templates and then include them ."

"If a template is used, I think it is better to write it by myself. This is also an exercise. But I think Xiaoqiang is good. You can edit it in a visual manner ." I personally think that the visual editing of template files is very important. It is not required that the creation of the template page should also have a fairly basic program development ." "For specific analysis of specific problems, whether the template is used or not, select the formed excellent show template class or write it by yourself. Everything is based on the specific project development, and cannot be left alone ." I feel that the existing templates are not perfect, either with few functions or slow speed, or I am doing well ."

"In summary, the advantages of PHP templates can make your code context clearer and the structure more rational. However, the development of PHP templates will always be much slower than the rapid development of PHP applications. In this case, it will affect the development of PHP applications. For every PHPer, no PHP template is the most suitable and perfect for him. Because the so-called PHP template is popular, it is not for individuals. Therefore, if you can fully understand the advantages and disadvantages of the template and the principles of the PHP application on the basis of a clear understanding of PHP features and applications, PHPer can get the PHP template that suits your development style. This is also one of the most important ideas of PHP. PHP only provides methods, approaches, rather than final solutions. All templates can be transformed into their own PHP templates like PHP applications and products. This is because the idea of the Creator is pinned on it.

Limited by various conditions, such as time and experience, you may think it is very difficult to create your own PHP template. In fact, what you need is not to re-construct a PHP template, but to select a PHP template that is closest to you. Because PHP needs to inherit and innovate. Of course, make your own PHP template step by step, and integrate the latest ideas and ideas in a timely manner. Personal PHPer can start from the details, from the places they need most and Their Development habits. The PHPer team can work collaboratively to localize PHP templates, especially for companies. Even if you have modified a symbol in the PHP template, it only indicates that you have modified it. It belongs to you. The most important thing is that your PHP template will never remain unchanged. It will grow with you and become a witness to your PHP history.

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.