
PHP에서 autoloading을 사용할 때, 등록된 autoloader를 해제하려면 `spl_autoload_unregister` 함수를 사용합니다. 이 함수의 사용 방법은 다음과 같습니다.
등록된 autoloader를 해제하려면, `spl_autoload_unregister` 함수에 등록된 autoloader의 이름을 전달하면 됩니다. 예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
spl_autoload_register(function ($class) {
// autoloader 코드
});
// 등록된 autoloader를 해제
spl_autoload_unregister(function ($class) {
// autoloader 코드
});
또는, 함수 이름을 전달할 수 있습니다.
#hostingforum.kr
php
spl_autoload_register('myAutoloader');
function myAutoloader($class) {
// autoloader 코드
}
// 등록된 autoloader를 해제
spl_autoload_unregister('myAutoloader');
또한, `spl_autoload_unregister` 함수는 여러 번 호출할 수 있습니다. 예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
spl_autoload_register(function ($class) {
// autoloader 코드
});
spl_autoload_register(function ($class) {
// 다른 autoloader 코드
});
// 등록된 두 개의 autoloader를 해제
spl_autoload_unregister(function ($class) {
// 첫 번째 autoloader 코드
});
spl_autoload_unregister(function ($class) {
// 두 번째 autoloader 코드
});
또는, 함수 이름을 전달할 수 있습니다.
#hostingforum.kr
php
spl_autoload_register('myAutoloader1');
spl_autoload_register('myAutoloader2');
// 등록된 두 개의 autoloader를 해제
spl_autoload_unregister('myAutoloader1');
spl_autoload_unregister('myAutoloader2');
2025-03-03 23:33