Reply to Re: directory paths...how does this work?

Your name:

Reply:


Posted by Jerry Stuckle on 12/08/43 11:36

John K wrote:
> In ASP/IIS if I want to point to a folder/directory in the root as an
> in include I write this...
>
> <!--#include virtual="/menu.asp" -->
>
> In PHP/Apache I have to do this...
> <?php include "menu.php" ?> or something like this....
>
> My problem is in asp I can reference this file from any
> folder/directory. For example, if I were here.... "/admin/default.asp"
> I could reference the include as is. In php I can't do this, at least
> I don't know how to. Another problem is that if there are file paths
> in the include itself this problem comes up again. I know I could
> write this <?php include "../menu.php"?> and it would find it's way to
> the file but what about the file paths in the include? This is a menu
> with relative paths to images.
>
> How can I point at a file in the root from any directory in my website
> using a relative path? I know I should probably avoid an http://
> reference.
>
> Thanks!!
>

Check out $_SERVER['DOCUMENT_ROOT']. It always points to the root
directory of your web site, no matter where that is.

You could, for instance, do something like:

<?php include($_SERVER['DOCUMENT_ROOT'] . '/include/menu.php'); ?>

or similar.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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