|
Posted by Christoph Burschka on 06/26/07 07:48
monomaniac21 wrote:
> hi all
>
> print the http path to the root of my site?
>
> marc
>
Three answers, depending on what you need:
1.) If you want the absolute path on the filesystem to the directory
where your site is (for reading files, for example), try this:
$document_root=$_SERVER['DOCUMENT_ROOT'];
This variable should never be shown on a public page, for security reasons.
2.) You want a link to the root of your site.
<a href="/">Home</a>
No PHP required. The browser will link to to the root of the site by itself.
3.) You absolutely have to print the URL of the root site, complete with
hostname. For the reason above, this is not necessary when linking.
echo "http://".$_SERVER['HOST_NAME']."/";
--
cb
Navigation:
[Reply to this message]
|