Freetor’s Blog

September 29, 2008

spl_autoload_register __autoload注册函数

Filed under: Uncategorized — Tags: , , , — admin @ 3:55 am

spl_autoload_register,有点陌生,查了下手册原来是__autoload的自定义注册函数。也就是把指定函数注册为__autoload,替代—__autoload完成其自动载入功能。

翻看zend framework的时候发现了一个函数spl_autoload_register,有点陌生,查了下手册原来是__autoload 的自定义注册函数。 也就是把指定函数注册为__autoload,替代—__autoload完成其自动载入功能。
这个是php5.1.2以来新增的函数,怪不得从来没有见到过。

顺便提一下 spl_autoload_unregister 不用说了,就是反注册,取消spl_autoload_register做的相关事情。

[div]

[color=#b2b4bf]spl_autoload_register[/color] — Register given function as __autoload() implementation

[/div]

[size=3]Description[/size]

bool [color=#b2b4bf]spl_autoload_register[/color] ( [callback $autoload_function] )

Register a function with the spl provided __autoload stack. If the stack is not yet activated it will be activated. If no parameter is provided the default implementation spl_autoload will be registered. When registering is successful the return value is true and upon failure false is being returned.

If your code has an existing __autoload function then this function must explicitly registered on the __autoload stack. This is because [color=#b2b4bf]spl_autoload_register[/color]() will effectively replace the engine cache for the __autoload function by either spl_autoload() or spl_autoload_call().

 

 

[div]

spl_autoload_unregister — Unregister given function as __autoload() implementation

[/div][size=2]Description[/size]

bool spl_autoload_unregister ( mixed $autoload_function )

Unregister a function from the spl provided __autoload stack. If the stack is activated and empty after unregistering the given function then it will be deactivated. When unregistering is successful the return value is true and upon failure false is being returned.

When this function results in the autoload stack being activated an existing __autoload function will not be reactivated.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress