Re: Sitewide Header & Footer Includes || Trouble with Relative Paths..........
| From: | Noah | Date: | Sat, 22 Feb 2003 22:30:07 +0000 |
| Subject: | Re: Sitewide Header & Footer Includes || Trouble with Relative Paths.......... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136655@lists.php.net to get a copy of this message | ||
Hey John.
Do you ever sleep? You've got a zillion posts in this news group..........
To answer your question, it's not that I'm afraid of absolute paths, it's
that I don't properly understand how to implement them.
I understand why the path references are not working when I move beyond the
root level directory, but getting the file reference to work beyond the root
is the tricky part for me.
For example, with $_CONF['path'] = '/home/me/www/program'; set in my
global_vars.inc how will I reference my image files? As
$path.image_file_name?
Could you provide an image file reference code snippet?
Let me know. Thanks,
--Noah
----- Original Message -----
From: "John W. Holmes" <holmes072000@charter.net>
To: "'CF High'" <noah@newminddesign.com>;
<php-general@lists.php.net>
Sent: Saturday, February 22, 2003 10:31 AM
Subject: RE: [PHP] Sitewide Header & Footer Includes || Trouble with
Relative Paths..........
> > How can I create a global header and footer include to my site pages
> where
> > I
> > don't rely on absolute paths to include and image files?
> >
> > I'm having trouble including my header and footer .inc's within a
> > multi-level directory structure -- the relative paths to images (and
> to
> > includes within includes) are not currently accessed within the
> current
> > directory structure.
> >
> > I'm assuming I'll need to prepend all image and include files with a
> path
> > variable that I set within each page, or something along those lines?
>
> When you call file.php, all includes and any nested includes are
> relative to the directory that file.php is in. That means if you include
> a file called subdir/file2.php and it attempts to include something,
> it's going to start looking for it in the same directory as file.php. No
> way around that.
>
> What's your fear of absolute paths? I always set two variables, the
> absolute path of my files and the web address.
>
> $_CONF['path'] = '/home/me/www/program';
> $_CONF['html'] =
> 'http://www.domain.com/program';
>
> for example. Then do all of your paths based off of those.
>
> If you don't want to do that, then you can probably play around with
> $_SERVER['PHP_SELF'] and basename() and the like to do what you want.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>