I decided to place it in a different file, called simply autoload.php, and then I require 'autoload'.php in the file where I want to autoload the classes.
Here's the code:
autoload.php
function __autoload($classname)
{
$filename = 'class.' . $classname . ".php"; //Note that my classes are all named class.classname.php
require_once($filename);
}
Keyra.php (the file I want to autoload classes in)
require_once 'autoload'; //Commence to use functions from classes I haven't required at the top
I was wondering whether this was an acceptable way to go about this.

New Topic/Question
Reply



MultiQuote






|