void
__autoload (
string
$class
)
你可以通过定义这个函数来启用类的自动加载。
<?php
class myClass {
public function __construct() {
echo "myClass init'ed successfuly!!!";
}
}
?>
./index.php
<?php
// we've writen this code where we need
function __autoload($classname) {
$filename = "./". $classname .".php";
include_once($filename);
}
// we've called a class ***
$obj = new myClass();
?>
*** At this line, our "./myClass.php" will be included!
__toString()和java同
Reflection .. to be continued