is_includeable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

is_includeable

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

If you know the path where the include is at, you could do file_exists().
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: is_includeable

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Another alternative is_file.

http://us2.php.net/is_file
Post Reply