PHP Class – simple template engine

I think everyone who started programming sooner or later came to the conclusion that it is necessary to collect ready-made scripts to optimize their work. Today I am starting a new section in which I want to publish my findings and developments of useful php classes and I will be glad if you, my dear readers, you will also help in the selection of useful classes.

I want the site to become a reference book for those, who wants not only to develop sites on control systems, but also to make their own control systems. The benefits in creating your own system will be huge, and to prove this, I will give a simple example.. Not so long ago, I was faced with the fact that when working with clients, I really lack systematic decisions. Every step when working with clients had to be recorded so that the client would not be stressed, I understand that they also have no point in teaching my program. After scouring the Internet, I found several good CRM systems for working with clients, but none of them suited my needs.. Setting up found systems was cumbersome , and the work would just turn into a bureaucracy. On the other hand, having a set of useful classes, one could easily develop a control system for oneself.

In this regard, I decided to lay out the first simple templating class, which will help novice developers understand what template engines are.

The code 1. Create a file to call the index.php class.

The code 2. Create a classes folder next to index.php. Create a file in the folder htmlGenerator.php and put code in it.

If you have already created a class with a template engine, it would be nice to create a template file.

Let's start by creating folders and files. /templates/pages/main.html. As you can see from the folder address templates should be in the root of the site, next to the file index.php. In folder templates there will be a folder pages, which defines the template type and finally the file main.html this is the template.

In file main.html enter the standard structure html pages with special tags. The labels must match the array indexes from the first code.

Example code template:

I would like to receive comments from you about the use of the class. If you have other examples of classes, I will be glad to look at them..

Good luck in development and let the new section "Ready-made php classes" become a reference book for our small community.

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

3 Responses

  1. admin says:

    The section was not created for step-by-step study, there is so much of it on the internet. A new section of the site was created for those, who needs useful code examples.

    What if someone wants to learn how to program?, then I think it's better to study with a coach. The result will always be more effective and faster, and often learning in a group is better than individually., as you can see a lot of errors, made by students from the group.

  2. Evgeny Odinets-Yarmolyuk says:

    I would like to learn how to program. Get into contact with me)

    • admin says:

      Hello, I'm Maxim. Site administrator wp-admin.com.ua. I think, for individual training it will be better to discuss everything by voice, What if there are questions after the discussion?, then you can write them in the comments, I will try to answer them. Questions and answers in the comments will be useful for regular readers of the blog.
      If you still want to study send me a letter with your data and wishes to the mail info@wp-admin.com.ua.

      Read more about what should be in the letter here.: I want to learn how to make websites looking for a tutor

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal