NogDog wrote:and then have each class's autoload() call that function. At least I would still only have to edit one function for any changes.
I actually don't see the point of a method named "autoload()" - unless you call it explicitly for some reason, which invalidates the point of having it. PHP's autoload mechanism goes looking for a global function with that name.
test.php
function __autoload($name)
{
require_once($name.'.php');
}
class Test1 extends Test2
{
public function __construct()
{
echo "I'm in Test1!";
parent::__construct();
}
}
$t = new Test1;
Test2.php
class Test2 extends Test3
{
public function __construct()
{
echo "I'm in Test2!";
parent::__construct();
}
}
Test3.php
class Test3
{
public function __construct()
{
echo "I'm in Test3!";
Test4::boing();
}
}
Test4.php
class Test4
{
public static function boing()
{
echo "Test4 goes boing!";
}
}