background image

 
 
Spl_autoload_register 
 
将函数注册到 SPL __autoload

 

函数栈中,直接看一个例子:

代码如下:
 

/*http.php*/

 

<?php 

class

 http 

public

 

function

 callname(){ 

echo

 "this is http"; 



 

/*test.php*/

 

<?php 
spl_autoload_register(

function

(

$class

){ 

if

(

$class

 == 'http'){ 

require_once

("/home/yejianfeng/handcode/http.php"); 


}); 
 

$a

 = 

new

 http(); 

$a

->callname(); 

 
 
spl_autoload_call 
 
调用 spl_autoload_register 中注册的调用函数, 

 

看下面的例子

代码如下:
 

/*http.php*/

 

<?php 

class

 http 

public

 

function

 callname(){ 

echo

 "this is http"; 


/*http2.php*/

 

<?php