You are here: Re: printing the http path to the root of my site? « PHP Programming Language « IT news, forums, messages
Re: printing the http path to the root of my site?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация