WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Simple Template Class/Example
Categories : PHP, Templates, PHP Classes Update Picture
JJ Harrison
Date : Sep 29th 2003
Grade : 3 of 5 (graded 12 times)
Viewed : 14253
File : No file for this code example.
Images : No Images for this code example.
Search : More code by JJ Harrison
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php

class template
{
/*
         DESCRIPTION:
         A VERY simple template class. No caching or advanced functionality.
         It simply opens a file and replaces any variable in the file with a syntax of
         '{VARIABLE}' It is primarily designed to keep layout HTML out of php files. Right now it is case sensitive but in future versions i will probably put in a setting for that.
        
I will probably update it with more functionality in the future but for now it could be extended by child classes etc.
        
         */
         var $tpl_dir = 'templates';
var $tpl_vars = array();
        
        
         // PRIVATE:
        
         function repvar($name, $value, $string)
{// Function to replace a variable
return str_replace('{'.$name.'}', $value, $string);
}
                 
         // PUBLIC:        
        
function addvar($name, $value)
         {// Add variable to be replaced in a template
         $this->tpl_vars[$name] = $value;
         }

function display($page)
         {
         $fhandle = file_get_contents($this->tpl_dir.'/'.$page);
                        foreach($this->tpl_vars as $name=>$value)
                        {
                         $fhandle = $this->repvar($name, $value, $fhandle);
                        }
                        return $fhandle;
         }
}

/*
//EXAMPLE
$tpl = new template;
$tpl->addvar('TITLE', 'Template Test');
$tpl->addvar('CONTENT', $content);
$tpl->addvar('MENU', 'Template Test');
echo $tpl->display('main.htm');
*/
?>



Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself.
Categories : PHP, PHP Classes, Templates, Complete Programs
Very minimal templating engine
Categories : PHP, PHP Classes, Templates
Parsing Simple Template Files and Data
Categories : PHP, PHP Classes, Templates, Regexps
Array Insertion
Categories : PHP, PHP Classes, Arrays
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Simple and fast user authentication
Categories : PHP, PHP Classes, Authentication
Form is a utility class for generating html forms. It provides form initialization and regex based data validation (both server and client side) with a convenient interface. This version obsoletes version 1.0a
Categories : HTML, PHP, PHP Classes, Regexps
Website Engine
Categories : PHP, HTML and PHP, Templates
HTML_Graphs provides a simple PHP interface for creating pure HTML charts.
Categories : Graphics, PHP, PHP Classes, Charts and Graphs
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item.
Categories : PHP Classes, PHP, Java Script, DHTML
HTTP gzip compression
Categories : PHP, PHP Classes, Compression, Zlib
Object() = Custom __autoload + Singleton. "automagically" instantiates a class and always retuns the same instance of the same class. It's pretty useful when you want to have persistence in objects.
Categories : PHP, PHP Classes, Algorithms
phpFormGenerator for Dynamic Form Generation from MySQL
Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP
MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP