First of all, make sure you include class file before using it:
include_once 'path/to/tpl_functions.php';
This should be done either in your index.php, or on top of a class that uses tpl_function . Also note the possibility of autoloading classes:
With PHP5, you should be able to automatically load classes. This means that you register a hook function that is called every time you try to use the class, the code file is not yet included. To do this, you do not need to include_once statements in each class file. Here is an example:
index.php or any application entry point:
spl_autoload_register('autoloader'); function autoloader($classname) { include_once 'path/to/class.files/' . $classname . '.php'; }
Now you can access the classes without worrying about including code files. Try:
$process = new process();
Knowing this, there are several ways to use the template_functions class
Just use it:
You can access the class anywhere in the code if you instantiate it:
class process { //all process with system and db public function doSomethging() { // create instance and use it $tplFunctions = new template_functions(); $tplFunctions->doSomethingElse(); } }
Members of the instance:
Take a process class, for example. To make template_functions available inside the process class, you create an instance member and initialize it somewhere where you need it, the constructor seems to be a good place:
//CMS System class class process { //all process with system and db // declare instance var protected tplFunctions; public function __construct() { $this->tplFunctions = new template_functions; } // use the member : public function doSomething() { $this->tplFunctions->doSomething(); } public function doSomethingElse() { $this->tplFunctions->doSomethingElse(); } }