Page 1 of 1
is_includeable
Posted: Tue Aug 08, 2006 1:35 am
by Luke
Is there a function in php to test whether a file is includeable? I want to load a file, but I want to do a check to make sure that it is within the include_paths
Like this:
Code: Select all
if(is_includeable($path)){
require_once($path);
}
else{
echo $path . " was not found in any of the include paths";
}
If not, is there a better way than traversing through the include paths and checking whether the file is there?
Posted: Tue Aug 08, 2006 1:39 am
by RobertGonzalez
If you know the path where the include is at, you could do
file_exists().
Re: is_includeable
Posted: Tue Aug 08, 2006 1:50 am
by jmut
The Ninja Space Goat wrote:Is there a function in php to test whether a file is includeable? I want to load a file, but I want to do a check to make sure that it is within the include_paths
Like this:
Code: Select all
if(is_includeable($path)){
require_once($path);
}
else{
echo $path . " was not found in any of the include paths";
}
If not, is there a better way than traversing through the include paths and checking whether the file is there?
check
http://php.net/include user comments. first comment might be what you look for.
although what Everah is good enough I think.
Posted: Tue Aug 08, 2006 2:02 am
by Luke
myself wrote:If not, is there a better way than traversing through the include paths and checking whether the file is there?
Guess not then

thanks
Posted: Tue Aug 08, 2006 2:11 am
by AKA Panama Jack
Another alternative
is_file.
http://us2.php.net/is_file