$functions = spl_autoload_functions();
foreach($functions as $function) {
spl_autoload_unregister($function);
}
取消註冊所有函數的好方法。
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
spl_autoload_unregister — 取消註冊指定的函式作為 __autoload() 的實作
從自動載入佇列中移除一個函式。如果佇列在移除指定的函式後被啟動且為空,則會停用該佇列。
當此函式導致佇列被停用時,先前存在的任何 __autoload 函式將不會被重新啟動。
callback
要取消註冊的自動載入函式。
$functions = spl_autoload_functions();
foreach($functions as $function) {
spl_autoload_unregister($function);
}
取消註冊所有函數的好方法。
在使用 spl_autoload_register() 呼叫後,恢復與 __autoload 的綁定
<?php
spl_autoload_register(array('Doctrine', 'autoload'));
// 一些處理程序
spl_autoload_unregister(array('Doctrine', 'autoload'));
// 但現在舊的 __autoload 不再被觸發
// 您需要使用:
spl_autoload_register('__autoload');
// 但如果 __autoload
// 函數尚未定義,這將拋出 LogicExeption,因此請使用:
function autoload__ ( $className ) {
if ( function_exists('__autoload'))
__autoload($className);
}
spl_autoload_register('autoload__');
?>
因此您可以將舊的 __autoload 定義在另一個檔案中
或許可以幫助一些人擺脫這個左右為難的困境