Re: Absolute or relative paths
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Absolute or relative paths

From: elektrophyte <elektrophyte@yahoo.com>
Date: Sun Jul 10 2005 - 22:26:22 CEST

Within plain HTML if you start a URL with "/" that refers to the root
level of the domain and your absolute URL will be good. For example,

<img src="/images/myFile.gif" />

should work no matter where it's used.

However everything's different within PHP code. If want to refer to an
absolute path inside of <? and ?> then you need to use a different
strategy. One thing that works is to precede your absolute path with
"$_SERVER['DOCUMENT_ROOT'] like this:

<? include($_SERVER['DOCUMENT_ROOT'] . '/include/navbar.inc'); ?>
Received on Mon Oct 17 21:05:01 2005