Hello. So far I've been using a simple template method. It works like this: in index.php I set a few variables (title of page, content source etc) and include template.php. From template.php I use $content_src to include the source file (in this case I would use index_content.php). This is pretty comfortable and pretty fast, but even a small projects requires tons of files. (double than it is supposed to).
Another option I've found on the internet is to use a variable to write the whole content code into it and then use it to replace special tag (like {content} ) in the template file or just include a template.php at the end and then just simply use echo to print the whole code. I don't like this option because it is going to work slowly and take shitload of memory. I mean that string is going to be really long and that means a lot of memory wasted. In addition long string means a lot of data to take care of which results as a time waste (copying and writing to it time is going to be a "wasted time").
To sum up, I have no idea how to make an effective template system in PHP. Could you suggest any?
P.S. Maybe it's just my option that a long string is bad, IDK, but you're not going to change my mind about it.
|