But if it is a news system or a content publishing system, it is very necessary to use the template technology. Because they both have One thing in common is that there is a type of page that uses the same style of page design. Based on the actual situation, such as the number of visits, the urgency of the project, and the programmer's proficiency in template technology, choose the template that is most suitable for the project. Technology.. This is the first choice. "
"I have been exposed to templates since I started learning PHP. I use the smarty template engine (officially supported and powerful). The longer I use it, the more I feel that PHP templates have many advantages. As long as it involves things displayed on the page, I will use templates to write them. It always feels awkward to write programs without templates. I think other PHPers will have the same feeling, because the original intention of the template design is to separate the code and the page and process them separately. After all, no one wants to write code and process the page at the same time. "
"Some people say that SMARTY is already very good, but others say that SUPERTPL is better, and some people prefer PHPLIB. I think each template has its own advantages and disadvantages. The key is up to you. What is needed for the project and what is best to use! "There is definitely nothing wrong with using templates. I originally used PHPLIB. After using it for a while, I felt that it was too simple. Each template variable had to be replaced by code, and each time a template was referenced, one line of code had to be written (maybe PHPLIB has I didn’t know about the batch processing function (I’m too bad at it), so I gave up. Later, when I was building a website with plog, I came into contact with smarty. I felt that smarty was too large and it could indeed speed up the development progress, but many functions were actually unused, so I ended up writing it myself. With the template engine, the function to be implemented by the template is very simple, which 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 press it. Based on my own experience and needs, I wrote some functions or classes to encapsulate some of the most commonly used processing for template output. "I use my own templates and have to write template parsing code, which is tiring. I choose to use existing excellent templates. "I have seen some very powerful people on other forums not using templates... maybe they are not at that level... Personally, I feel it is better to use templates... at least they can divide the work... and speed up the development. Use your own template? I don’t think it’s necessary... Just use the ready-made ones. Add some practical functions that you want to learn based on the ready-made ones. "I don't use a template engine, but I also use templates, but it's just different from yours. Because the template engine is too slow, it's hard to use."
"I use a third-party one, preferably open source. . As for which one to use, it depends on personal preference. "I still prefer to use my own template that is simple and practical." "Due to performance considerations, I generally do not use universal templates. I will make some trade-offs based on the actual situation, which has certain limitations. "Decide whether to use templates and which templates to use based on your needs. There is always no harm in being flexible." Personally, I like simple and fast templates. You can consider using ready-made templates, but generally I will optimize them according to the actual project and use them. Some functions that are not available are deleted, etc. "
"The advantage of PHP templates is that they generally do not cause bottlenecks. As for the efficiency, they mainly affect the following points:
1. After the program and template are separated, one file becomes two If there are one or more, then reading the IO of the template is also time-consuming
2. Parsing the template is relatively complicated. Generally, N preg_match, preg_replace and other functions are needed to process or replace
3. Template The loading and replacement work obviously requires more memory than not using templates
So to improve efficiency, pay attention to the following points:
1. Choose a template parsing program that supports compilation and caching. This The performance benefit is the most obvious, it depends on how you apply it flexibly
2. Keep the parsing program as simple as possible. If all functions are included, it will be more convenient to use, but the performance will be worse
3. When making HTML template pages It also follows simple principles, such as following xhtml standards, and trying not to split a page into many templates and then include them. ”
“If you use a template, I think it’s better to write one yourself if you have the ability. This is also exercise. But if you want to use it, I think Xiaoqiang is good. Can be edited under visualization. "I personally think that the visual editability of template files is very important. We cannot require that the production of template pages must also have a considerable foundation in program development." "Analyze specific problems in detail, whether to use templates or not, choose the excellent template classes that have already been formed or make your own To write, everything is based on specific project development, and you can’t rely on one. "I feel that the existing templates are not perfect enough, or have few functions, or are slow, so it is better to do it yourself. ”
"To summarize, 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 PHP application development. For every PHPer, no PHP template is the most suitable and perfect for him. Because the so-called PHP template is a popular thing, it is not personal. Therefore, if you can understand the characteristics of PHP. , Based on a clear understanding of the advantages and disadvantages of templates and the principles of PHP application, PHPer can get the PHP template that suits his own development style. This is also one of the most important ideas of PHP, provided by PHP. It’s just a method, not a final solution. So templates, like PHP applications and products, can be transformed into their own PHP templates because they are subject to various conditions. There are limitations, such as time and experience, so you may think that it is very difficult to make your own PHP template. In fact, what you need is not to reconstruct a PHP template, but to choose a PHP template that is closest to you and modify it because PHP needs to be inherited. , Innovation. Of course, make your own PHP template and implement it step by step, and incorporate the latest ideas and concepts in a timely manner. Individual PHPers can start with the details, where they need it most and their own development habits. Working together to localize PHP templates is especially practical for companies. Even if you just modify a symbol in the PHP template, just a symbol can show that you have modified it, and it belongs to you. The best thing is that your own PHP template will never be fixed. It will grow with you and become a witness of your PHP journey.
PHP does not require you to be very proficient in grammar; PHP does not require you to be very proficient in grammar. Develop many libraries by yourself; PHP does not need you to worry about performance, stability and other language characteristics. What PHP needs is your logic; what PHP needs is your creativity; what PHP needs is your ideas! ”
http://www.bkjia.com/PHPjc/446006.html