Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the basics of smarty template engine

Shulou Source: shulou.com Published: 2022-06-03 09:22:11 10月27日 Update

This article mainly explains "what are the basics of smarty template engine". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the basics of smarty template engine".

The details are as follows:

I. basic concepts

1. What is mvc?

Mvc is a kind of development mode, the core idea is: data input, data processing, data display forced separation.

two。 What is smarty?

Smarty is a template engine for php. More specifically, it can help developers better separate program logic from page display.

Operation principle of 3.smarty

A template file is a template that displays data, in which the data to be displayed is replaced by placeholders.

When smarty is running, it will read the template file, replace the placeholders in the template file with real data, and output a processed php file for the server to run.

Write a smarty template by yourself

In order to better understand the smarty template, now write your own smarty template-minismarty, so that you can have a more in-depth understanding of how smarty works.

1. Create a new project minismarty

Create a new template file path: templates

The compiled file path of the new template file: templates_c

Create a new template file: intro.tpl

Create a new running file: index.php

Create your own smarty, that is, the file that processes the template: cls_MiniSmarty.php

two。 Write index.php files

Tags: Files templates data compilation content paths runs engines knowledge methods fundamentals basics parameters caching generation function that is processing learning principles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Tech Info Microsoft NVidia Huawei