Re: include question
| From: | PJ | Date: | Fri, 06 Mar 2009 15:35:46 +0000 |
| Subject: | Re: include question | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289468@lists.php.net to get a copy of this message | ||
Daniel Brown wrote:
> On Fri, Mar 6, 2009 at 08:53, Stuart <stuttle@gmail.com> wrote:
>
>>> 1.) We use regular open tags to be compatible with all stock
>>> PHP configurations.
>>> 2.) We echo out the response from dirname() so that it's
>>> output to the HTML source.
>>> 3.) We use dirname() twice, so it gives the dirname() of the
>>> dirname(), rather than '..'.
>>> 4.) There are double underscores around FILE. The same is
>>> true with LINE, FUNCTION, etc.
>>>
>> 5.) dirname() gives you the full path on disk, not the URL. Usually you can
>> just remove the document root path to get the URL. This could be in
>> $_SERVER['DOCUMENT_ROOT'] but you can't rely on that between servers or when
>> the config changes.
>>
>
> 6.) When used in conjunction with realpath()[1], it will
> resolve the absolute local pathname.
>
> ^1: http://php.net/realpath
>
>
Sorry, guys, but none of this works...
I get the document root which is wonderful but it misses the vhost root
completely.
So what I get both with realpath and $SERVER['DOCUMENT_ROOT']is
/usr/local/www/apache22/data/images/file.gif or
/usr/local/www/apache22/data/../images/file.gif
and that, of course misses the main directory for this site which is
ptahhotep
In /ptahhotep/file.php - the path for the image.gif is images/image.gif
In /ptahhotep/admin/another_file.php/ the path for the image.gif is
../images/image.gif
But as I try different variations, I finally see that adding the root
directory name for the site does the trick.
Have I discovered something new here? :-)
--
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- pj@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php