Home > PHP Framework > ThinkPHP > body text

The difference between smarty and thinkphp

(*-*)浩
Release: 2019-09-11 13:21:30
Original
4760 people have browsed it

The difference between smarty and thinkphp

Smarty is a template engine written in PHP and is currently one of the most famous PHP template engines in the industry.

It separates logical code and external content, providing an easy-to-manage and use method to logically separate PHP code that is originally mixed with HTML code.

To put it simply, the purpose is to separate PHP programmers from front-end personnel, so that programmers change the logical content of the program without affecting the front-end personnel's page design, and front-end personnel re-modify the page without affecting the program. Program logic, which is particularly important in multi-person collaboration projects.

Advantages (Recommended learning: PHP programming from entry to proficiency)

1. Speed: Programs written with Smarty can achieve maximum speed Improvement, this is compared to other template engine technologies.

2. Compiled type: A program written in Smarty needs to be compiled into a non-template technology PHP file at runtime. This file uses a mixture of PHP and HTML, and the WEB request will be sent directly the next time the template is accessed. Convert to this file without recompiling the template (when the source program has not been changed)

3. Caching technology: A caching technology selected by Smarty, which can store the content that the user finally sees. The HTML file is cached into a static HTML page. When Smarty's cache attribute is set to true, the user's WEB request will be directly converted to this static HTML file within the cachetime set by Smarty. This is equivalent to calling a Static HTML files.

4. Plug-in technology: Smarty can customize plug-ins. Plug-ins are actually some custom functions.

5. If/elseif/else/endif can be used in templates. Using judgment statements in template files can very conveniently reformat the template.

Not suitable for using Smarty

Content that needs to be updated in real time. For example, like stock display, which needs to update data frequently, using smarty for this type of program will slow down template processing.

Small projects. For small projects where the artist and programmer are both simple because the project is simple, using Smarty will lose the advantage of PHP's rapid development to a certain extent.

(PS: However, for the sake of standardization of the entire project, please try to use the template engine. In fact, if you get used to it, the development speed will be faster. The above are the problems encountered by developers who are not used to the template engine)

ThinkPHP was born to simplify enterprise-level application development and agile WEB application development. It was first born in early 2006, and was officially renamed ThinkPHP on New Year's Day 2007, and was released under the Apache2 open source agreement.

ThinkPHP has been adhering to the simple and practical design principle since its birth. While maintaining excellent performance and minimal code, it also focuses on ease of use. And it has many original functions and features. With the active participation of the community team, it is continuously optimized and improved in terms of ease of use, scalability and performance.

ThinkPHP is a fast, compatible and simple lightweight domestic PHP development framework. It was born in early 2006, formerly known as FCS. It was officially renamed ThinkPHP on New Year's Day in 2007. It is released under the Apache2 open source agreement. , transplanted from the Struts structure and made improvements and improvements. At the same time, it also borrowed many excellent foreign frameworks and patterns, used object-oriented development structures and MVC patterns, and integrated the ideas of Struts with TagLib (tag library) and RoR's ORM Mapping and ActiveRecord modes.

ThinkPHP can support server environments such as windows/Unix/Linux. The official version requires PHP5.0 or above. It supports MySql, PgSQL, Sqlite databases and PDO extensions. The ThinkPHP framework itself has no special module requirements. The specific application system operating environment requirements depend on the modules involved in development.

As an overall development solution, ThinkPHP can solve most needs in application development, because it includes the underlying architecture, compatibility processing, base class library, database access layer, template engine, caching mechanism, and plug-ins Mechanism, role authentication, form processing and other commonly used components, and it is more convenient for cross-version, cross-platform and cross-database transplantation. And each component is carefully designed and perfected, and the application development process only needs to focus on your business logic.

The above is the detailed content of The difference between smarty and thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template