Re: including files outside of document root
| From: | Daniel Brown | Date: | Wed, 23 Jan 2008 01:17:30 +0000 |
| Subject: | Re: including files outside of document root | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267874@lists.php.net to get a copy of this message | ||
On Jan 22, 2008 8:09 PM, Richard Lynch <ceo@l-i-e.com> wrote:
> Nothing peeves me more than some badly-conceived web-app with no way
> to move the include files out of the web-tree.
You may disagree with me on this here, Rich, but the way I do it
is to have a single include_files.php file containing all of the files
that need to be included as a whole, and a single configuration
variable to set where those files are located. I know that they don't
all have to be included in that file, but I find it makes it easier,
since I use all of them with every page load.
I also employ a function safe_include($filename) that uses a
combination of file_exists($filename), is_file($filename), and
is_readable($filename). If the function fails, no PHP error message
is output if the file can't be found, and the script doesn't
necessarily halt. If it's a critical file, instead a message is
dispatched to my email, and a friendly message is placed on the site
informing the user that a technical error has been encountered and
will be repaired ASAP.
--
</Dan>
Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since
Nineteen-Seventy-[mumble].