RE: [PHP] Include/require
| From: | David Freeman | Date: | Thu, 20 Jun 2002 05:43:37 +0000 |
| Subject: | RE: [PHP] Include/require | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103081@lists.php.net to get a copy of this message | ||
> Is there a way to make include()/require() take a a full
> virtual path? I.e. require_once("/inc/myinc.php")? It gets
> a little annoying to do require("../../../../file.php").
Sure, they should work either way. The only real gotcha is knowing what
a full path will be in relation to the web server when it goes to do the
include/require. For example, an include for '/inc/myinc.php' has
particular meaning under *nix that may have it not work even though it
looks that way to an ftp proggy.
Part of my normal configuration file for php projects is a declaration
of $webroot as the path to a document as called from within a browser
(ie. $webroot = "http://www.some.domain/some/directory")
and $fileroot
as the path to a document as called from the filesystem (ie. $fileroot =
"/home/some/user/directory") and then just append as appropriate (ie.
Include($fileroot/inc/someinclude.php) and away you go.
CYA, Dave