Restore the binding to __autoload after using a spl_autoload_register() call
<?php
spl_autoload_register(array('Doctrine', 'autoload'));
// some process
spl_autoload_unregister(array('Doctrine', 'autoload'));
// but now the old __autoload is not triggered anymore
// you need to use :
spl_autoload_register('__autoload');
// but this will throw a LogicExeption if the __autoload
// function is not defined yet, so use:
function autoload__ ( $className ) {
if ( function_exists('__autoload'))
__autoload($className);
}
spl_autoload_register('autoload__');
?>
So you can define your old __autoload in another file for example
May helps some folks in this catch 22
spl_autoload_unregister
(PHP 5 >= 5.1.2)
spl_autoload_unregister — 指定した関数の、__autoload() の実装としての登録を解除する
説明
spl が提供する __autoload スタックから、関数の登録を解除します。 スタックがアクティブであり、かつこの関数の実行後にスタックが空になった場合は スタックが非アクティブ化されます。
この関数の結果として autoload スタックがアクティブになったとした場合に、 既存の __autoload 関数が再アクティブ化されることはありません。
パラメータ
- autoload_function
-
登録を解除したい autoload 関数。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。
spl_autoload_unregister
Julien B.
07-Jul-2009 04:31
07-Jul-2009 04:31
