spl_autoload_register
test.php
<?php
class MyClass {
public static function autoload($className) {
require ($className.".php");
}
public static function autoload2($className) {
require ($className."test.php");
}
}
spl_autoload_register(array('MyClass', 'autoload2'));
spl_autoload_register(array('MyClass', 'autoload'));
spl_autoload_register(array('MyClass', 'autoload'),true,true); //注意第三个参数..如果为true,会先执行他
$hass = new hass();
echo $hass->name; //222
?>
hasstest.php
<?php
class hass {
public $name = "222";
}
?>
hass.php
<?php
class hass {
public $name = "1";
}
?>