在php5中实现自动装载类库
<?php
// test.inc.php
class Test
{
var $name;
function getName()
{
return $this->name;
}
function setName($n)
{
$this->name = $n;
}
}
?>
<?php
// test.php
// autoload class file
function __autoload($class_name) {
include($class_name.'.inc.php');
}
// instantiate a class
$t = new Test;
// Call class action
$t->setName('Stangly Wrong');
echo $t->getName();
?>