2
I created a simple script to automatically load classes using spl_autoload_register
, but I noticed a strange behavior when I use class_exists
the spl_autoload_register
is executed, example:
<?php
function autoLoadClass($name) {
echo 'spl_autoload_register: ', $name, '<br>';
}
spl_autoload_register('autoLoadClass');
class_exists('Foo');
class_exists('Bar');
class_exists('Foo\\Bar');
Exit:
spl_autoload_register: Foo
spl_autoload_register: Bar
spl_autoload_register: Foo Bar
Is that correct? Is there any way to do the spl_autoload
not be called when using class_exists
?
+1 this question is useful.
– Wallace Maxters