Include if file exists?
| From: | Jay | Date: | Fri, 27 Aug 2004 10:16:32 +0000 |
| Subject: | Include if file exists? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-194918@lists.php.net to get a copy of this message | ||
Hi!
Is there a ready to use PHP function for including ONLY if the file exists?
I tried it like this:
[main.php]
include_once("lib.php");
....later
includeIf("somefile.php");
[lib.php]
function includeIf($filename)
{
if (!file_exists($filename))
{
include_once($filename);
}
}
You see the problem. The somefile.php seems to be included in the wrong file. It should be included in the main.php instead of lib.php.
How can i still have the function in lib.php but the file will be included in main.php
Thanx in advance
J