在了解这个函数之前先来看另一个函数:__autoload。
一、__autoload
这是一个自动加载函数,在PHP5中,当我们实例化一个未定义的类时,就会触发此函数。看下面例子:
printit.class.php  | 
<?php  | 
class PRINTIT
 {  | 
 function doPrint()
 { | 
  echo 'hello
 world'; | 
 } | 
} | 
?>  | 
index.php  | 
<? | 
function __autoload( $class )
 { | 
 $file = $class . '.class.php';   | 
 if ( is_file($file)
 ) {   | 
  require_once($file);   | 
 } | 
}  | 
$obj = new PRINTIT(); | 
$obj->doPrint(); |