Re: Referring to Parent Folders
| From: | Richard Davey | Date: | Fri, 13 Feb 2004 12:30:46 +0000 |
| Subject: | Re: Referring to Parent Folders | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177595@lists.php.net to get a copy of this message | ||
Hello Vinny,
Tuesday, February 10, 2004, 6:18:09 AM, you wrote:
V> [doc root]
V> -----[php]
V> ---------- script.php
V> ---------- [some folder]
V> --------------- [another folder]
V> -------------------- current.php
V> So my question is, is this simply a PHP config problem?
Nope. Nothing to do with Apache either. The problem is that you're
assuming the include function knows what your doc root is. But think
about it - how can it? It's looking for files on a FILESYSTEM level,
not a URL level.
Assume the following is the actual directory structure on your server:
/usr <-- Top Level
/usr/home
/usr/home/vinny
/usr/home/vinny/public_html <-- Where your web files live
Say you want current.php to include "script.php" as in your example.
You have two choices:
include "../../script.php";
Which as you pointed out isn't ideal if you ever need to move around.
Alternatively:
include "/usr/home/vinny/public_html/php/script.php";
Which will never fail as long as you never move script.php
Why not set-up a variable in a common include file (something like
$basedir = "/usr/home/vinny/public_html/php") and then you can just do
this:
include "$basedir/script.php";
Or whatever you need to do.
The other solution would be to place your local (home) directory into
the search path for include in the php.ini file.
--
Best regards,
Richard mailto:rich@launchcode.co.uk