Package loader.

A simple class loader.

<?php
class pkg {
	public static $pkg = array();
	
	function __construct() {
		//
	}
	public function load_pkg($pkg) {
		# Load Package File
		require_once('./pkg/' . $pkg . '.pkg.php');
		# Initialize Package
		pkg::$pkg[$pkg] = new $pkg;
	}
}
?>

Usage

Edit the necessary variables, load packages with "pkg::load_pkg("PACKAGENAME");"

Classes will be initialized in pkg::$pkg['PACKAGENAME'];

This keeps things neat, as well as saving you from including each and every class file in your script.


Comments

Add your comment