PHP

The PHP: Hypertext Preprocessor for creating dynamic web-page content.

The PHP Template

Here is the source code for a class that you can use to construct dynamic web-site pages from skeletal template files, Template.php. What it does seems so obvious that I cannot justify even commenting it:

<?php
class Template
{
    private $file;
    private $vars;
 
    function __construct($file) { 
        $this->file = $file;
    }
 
    public function set($name, $value) {
        if (is_object($value)) {
            $this->vars[$name] = $value->fill();
        } else {

The Problem: How It Works vs. How it Looks

I have used PHP to power web-sites with dynamic content now for many years and for all that time I have been dissatisfied with how difficult it has been to keep separate the concerns of how the sites look from how the sites work. I've seen people refer to this topic as "presentation logic" verses "business logic", but whatever it is called the problem, to me, always comes down to "how does it look" vs. "how does it work".

A Simple PHP Template "Engine"

Here is a very simple template mechanism for dynamic web-site content generated by PHP. This approach lets you cleanly separate the "presentation logic" from the content or "business logic" without introducing the additional complexity of a separate template pseudo-language.

Syndicate content