Hi guys!
Be careful and don't forget about second boolean argument $autoload (TRUE by default) when check exists class after spl_autoload_register. Propose short example
file second.php
<?php
class Second {}
?>
file index.php
<?php
class First
{
function first($class, $bool) {
spl_autoload_register( function($class) {
require strtolower($class) . '.php';
});
echo class_exists($class, $bool)?'Exist!!!!':'Not exist!';
}
}
new First($class = 'Second', $bool = true); new First($class = 'Second', $bool = false); ?>
Because __autoload executing much earlier than boolean returned, imho..