An alternative way of writing an autoload-function. From my personal experience it works and returns the proper boolean values.
Feedback is welcome!
<?php | |
function traditional_autoload($class) | |
{ | |
$class = 'path/to/' . $class . '.php'; | |
$file = stream_resolve_include_path($class); | |
if ($file) { require $file; } | |
return $file !== false; | |
} | |
function alternative_autoload($class) { | |
return false !== (@include('path/to/' . $class . '.php')); | |
} | |