[thelist] include paths with php - previewing in browser locally and on server
Maximillian Schwanekamp
lists at neptunewebworks.com
Fri Apr 29 12:51:39 CDT 2005
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/
More information about the thelist
mailing list