Php introduces the namespace with the & quot; split syntax, which is unique and unaccustomed to first use. In addition, it uses well-designed directory results for management, namespace management can also be implemented. I personally think that the newly introduced namespace and used are all superfluous. Besides the template engine, I personally think the model... php introduces the namespace syntax separated by "\", which is unique and unaccustomed to use at first. Moreover, it can manage namespaces with well-designed directory results, I personally think that the newly introduced namespace and used are all superfluous.
Besides the template engine, I personally think that the only use of the template engine is to separate the write interface (Template) from the write business logic so that the artist can develop templates independently to reduce the workload of programmers. However, for the artist, learning a template tag similar to {var} is no less difficult than writing php code to directly fill the template. Templates without php syntax require template compilation, which consumes performance. In addition, what are the benefits of various template engines?
Please do not give a simple answer: "Your project is not large enough and there are not many parallel developers"
Reply content:
Php introduces the namespace syntax separated by "\", which is unique and unaccustomed to use at first. Moreover, it can manage namespaces with well-designed directory results, I personally think that the newly introduced namespace and used are all superfluous.
Besides the template engine, I personally think that the only use of the template engine is to separate the write interface (Template) from the write business logic so that the artist can develop templates independently to reduce the workload of programmers. However, for the artist, learning a template tag similar to {var} is no less difficult than writing php code to directly fill the template. Templates without php syntax require template compilation, which consumes performance. In addition, what are the benefits of various template engines?
Please do not give a simple answer: "Your project is not large enough and there are not many parallel developers"
The namespace is not used much. skip this step. Let's talk about the template engine.
The use of the template engine actually comes back to the original requirement: simply to output html as conveniently as possible.
Although php is different from many other languages, it was initially designed to facilitate the implementation of some dynamic features in a bunch of html (so many projects actually use php to implement templates, for example, wordpress is a bunch of php), but compared with smarty (and other template engines), when writing html directly, it is indeed more convenient for smarty in most cases, because the smarty engine is specially optimized for compiling html. For example, in smarty, you need to escape a variable in html:
{$xxx|escape:'html'}
What about php?
If it is changed to the quotation mark escape, smarty only needs to change the html to quotes. The format remains the same and it is comfortable in writing and reading. For php, of coursehtmlspecialcharsChangeaddslashesYes, but php functions are really difficult to use (hard to remember and write). Many similar functions do not have a unified convention on the sequence of variables, who uses it )...... I have a deep understanding of this. I wrote a project in the past 10 years and thought it was not necessary to use smarty. So I used php to implement it. It was very painful to write it, if you know more about smarty at that time (I just heard that it seems to be a heavyweight and useless), it is absolutely impossible to see this situation.
Recently, webpy has been widely used. I think webpy's template engine is better than smarty in html Escape: It is escaped by default. When variables need to be referenced on the page, direct$xxxThat's all. If you do not need to escape, it is easy:$:xxx.
These features are optimized specifically for html development. For php, a language that is very casual at the very beginning and will be very random in the future, it is indeed much better.
Compilation and efficiency: in fact, most template engines have compilation caches, but compilation is required during the first access. The overhead brought by this process is almost negligible. Regarding efficiency, You can also talk about php by the way-the efficiency is not very good, and there is really no overhead. (P.s. I am almost new to php)
Use and so on are the core features of namespaces. Obviously, this is a reference from C ++ and other languages.
The purpose of a namespace is to enhance the management of identifiers. Not all cases require a very long and complete qualified name, therefore, use and other mechanisms are required to abbreviated the namespace of the identifier.
Of course, the PHP namespace is really not well designed, such as the wonderful backslash, and the function and variable functions are limited.