[thelist] include paths with php - previewing in browser locally and on server

Bruce Gilbert webguync at gmail.com
Fri Apr 29 14:01:21 CDT 2005


thanks for the reply, I will give this a shot!

On 4/29/05, Maximillian Schwanekamp <lists at neptunewebworks.com> wrote:
> Bruce Gilbert wrote:
> > I have a question regarding paths with php includes.
> > ...when I try to do a
> > reletave path, something like <?php
> > require("/includes/nav-parents.htm"); ?>
> > I get file not found errors...any suggestions?
> 
> You can usually do a path relative the script, e.g. <?php
> require('../includes/nav-parents.htm'); ?>, assuming you have "." as an
> item (usually it's the first) in your include_path php.ini setting.
> 
> Otherwise, to get the absolute path of your running script on Apache,
> you could use $_SERVER['DOCUMENT_ROOT']; On IIS it's a little trickier -
>   you might use $_SERVER['PATH_TRANSLATED'] and then use
> $_SERVER['PATH_INFO'] to parse out the absolute path to the webroot of
> your site.  Then you could either use ini_set and/or define a constant
> with your absolute path.
> 
> Or maybe someone else will have a better suggestion!
> 
> --
> Maximillian Von Schwanekamp
> http://www.neptunewebworks.com/
> 
> 


-- 
::Bruce::


More information about the thelist mailing list