Sorry for possiblely reduplicate asking. But it's hard to use this confusable keyword to search a answer.
So here is scenario:
I try to get a advise to make my simple autoloader. Here is i made so far:
private function getAutoInclude($classfile) {
$classfileLower = strtolower($classfile);
if (isset($this->configs['Paths']['base.'.$classfileLower])) { // Use path scope to locate file first
return require_once($this->configs['Paths']['base.'.$classfileLower]['Path']);
} elseif ($this->configs['LibRoot'] && strpos($classfile, '\\') !== false) { // If above not work, use namespace to locate file
return require_once($this->configs['LibRoot'] . DIRECTORY_SEPARATOR . str_replace(array('\\', '/', '_'), DIRECTORY_SEPARATOR, ltrim($classfile, '\\')) . '.php');
}
return false;
}
It works well so far but only thing confused me is, some people tells me i must to do a file_exists check on the file i'm including so i can include it more safer AND more faster.
So consider the file i want to included must be there each time i include it, will i really have to file_exists in this scenario or not?
(I know this question just like a newbie asked. But when i heard people say if file_exists can make file include faster, it break some of my knowledge on PHP.)