Explaining the role of PHP templates in detail _php tutorial

Source: Internet
Author: User
Tags learn php php template smarty template
In learning

, in fact, the most important thing is to suit their own project needs, and not to suit their own habits. For example, an enterprise's propaganda website, the amount of visits is not big, the update amount is not big, with what all the same, even without, direct php+html write may be the fastest. But if it's a news system, or a content publishing system. In this way, it is very necessary to use the technology of template. Because they all have a common place, is a kind of page to use the same style of page design. Depending on the actual situation, such as the size of the traffic, the urgency of the project, and the programmer's proficiency in the template technology, select Choose the template technology that best fits your project. This is the first choice. ”

"Starting to learn PHP from the beginning of contact with the template, I use the Smarty template engine (official support, powerful), the longer the use of time more and more feel that the template is a good thing." As long as the page to relate to the display of things, I will use the template to write, if you do not use the template to write the program always feel awkward. I think the other phper will feel the same, because the PHP template is designed to separate the code and the page separately, after all, no one would like to write code, while processing the page. ”

"Some people say that Smarty has been very good, but also some people say supertpl better, but also some people prefer to phplib I think each template has its own merits, but also have their own not group, the key to see what your project needs, with what the best! "[From FEIFENGXLQ]" with the template is definitely not wrong originally used Phplib, after a period of time, it feels too simple, each template variable to write code to replace, each reference to a template also have to write a line of code (perhaps Phplib has a batch processing function, I do not know, and then gave up, and later with the Plog to build a station contact with the smarty, feel smarty too large, indeed can speed up the development progress, but a lot of functions are not actually used, therefore, the final is to write the template engine, the template to achieve the function is very simple, is a replacement for a template variable, plus include additional templates and foreach block manipulation capabilities. ”

"I still use phplib, but I will write some functions or classes to encapsulate some of the most commonly used processing for template output, as per my experience and needs. "[From Seraph]" I use my own php template, but also to write template parsing code, tired ah. I choose to use an existing excellent template. "[From Bantu]" I saw some very powerful people on other forums without templates ... Maybe it's not that ... Personal feeling is good for using templates. At least it can be divided. Speed up development. Use your own template? Feel no need to ha ... With ready-made on the line. Add some of the practical features you want to learn on a ready-made basis. "[From Phzzy]" I do not use the template engine, but I also use templates, just unlike yours. Because the template engine is too slow to feel good. ”

"I use third-party, preferably open-source. As for which, see a personal hobby. "[From Leeyupeng]" I still prefer to use my own template simple and practical. "[From Xi Day]" due to the performance, I generally do not use a generic template, will be based on the actual situation to do some trade-offs, with certain limitations. "[from Ben]" as needed to decide what template to use without using the template. There is always no harm in being flexible. "[From Xlmo]" individuals like simple and fast templates, you can consider using ready-made PHP templates, but generally based on the actual project optimization, the use of some of the functions are not used to remove. ”

"The use of templates generally does not lead to bottlenecks, as to the impact of point efficiency mainly so several points:

1, the program and template separation, a file becomes two or more, then read the template This IO is also a point of time
2, the resolution template is relatively complex, generally requires n preg_match,preg_replace and other functions to deal with or replace
3, the template loading and replacement work clearly need to use more memory than not using the template

So raise the efficiency note the following points:

1, template resolver selection to support the compilation and caching, this performance benefit is the most obvious, see how flexible application of their own
2, the resolution program as simple as possible, what functions are put in it is convenient to use, the performance is also poor
3, HTML template page is also to follow the simple principle, such as the XHTML standard to do, try not to split a page into a number of templates and then include. ”

"If I use a template, I think I have the ability to write a good one myself." This is also exercise. But I think the cockroach is good. can be edited under visualizations. "[From Jejwe]" I personally think that the visual editing of template files is very important. Can not require the production of template pages should also have a considerable program development basis. "[From Seraph]" specific analysis, PHP template use or not, choose the excellent template has been formed or to write their own, everything is based on the specific project development, can not die for which. "[From Deepseath]" feel that the existing templates are not perfect, either function less, or slow, or do their own good. ”

"Summary, PHP template can make your code context clearer, structure more rationalization." 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 a popular thing, not for personal. Therefore, if you can understand the PHP features, applications have a clear understanding of the advantages and disadvantages of the template and the principle of PHP application, Phper can get their own development style for their own PHP template. This is one of the most important ideas in PHP, and PHP offers only methods, paths, and not final solutions. So templates and PHP applications, products can be transformed into their own PHP template. Because this is the idea of the creator.

Limited to a variety of different conditions, such as time, experience, so you may think it is very difficult to make a php template of their own. In fact, what you need is not to reconstruct a php template, but instead choose a php template that is closest to your own to transform it. Because PHP needs to inherit and innovate. Of course, make a php template of your own step-by-step implementation, and timely integration of the latest ideas and ideas. Personal Phper can start from the details, from the place where you need it most and your own development habits. The Phper team can collaborate on the localization of PHP templates, especially for companies. Even if you just change a symbol inside a php template, just a symbol can show that you have transformed it, and that it belongs to you. Most importantly, your own PHP template is never fixed, it will accompany you to grow, it will be your PHP journey witness.

PHP does not require a very proficient syntax; PHP does not require you to develop many libraries yourself; PHP does not require you to worry about the features of the language itself, such as performance, stability, and so on. PHP needs your logic; PHP needs your creativity; PHP needs your mind! ”


http://www.bkjia.com/PHPjc/446196.html www.bkjia.com true http://www.bkjia.com/PHPjc/446196.html techarticle in learning, in fact, the most important thing is to fit their own project needs, and not to suit their own habits. For example, an enterprise's propaganda website, the volume of visits is not big, the update amount is not big, with what is the same, very ...

  • Related Article

    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.