例子:
类名.php
<?php echo "This will crash all"; ?>
在另一个文件...
foreach ($FILENAMES_WITHOUT_DOT_PHP as $name => $value) {
if (class_exists( $value )) {
echo "ClassName exists...";
}
else {
echo "ClassName doesn't exists....";
}
}
这段代码的输出是: 这将导致所有崩溃
取而代之的是: ClassName 不存在....
自动加载功能:
function __autoload( $var_class )
{
require_once( "$var_class.php") ;
}