You are here: Re: path using / or ../ « All PHP « IT news, forums, messages
Re: path using / or ../

Posted by Martin Mouritzen on 11/01/06 19:51

On 1 Nov 2006 11:10:05 -0800, "jesbuddy07" <jesbuddy07@gmail.com>
wrote:

>Can anyone point me to a right direction in terms of using / and ../
>directives to point to a file using PHP?
>
>i'm so confused when to use / or ../ or sometimes even without /.
>
>i'm writing php file in a /x/y directory, and the file i want to
>include resides is /x/z directory. in /x/y directory, I tried the
>following statements, but none of them works
>
>include("x/z");
>include("/x/z");
>include("../x/z");
>
>can any PHP guru out there please tell me when to use /, ../ or none at
>all??

I can try:

/ at the start means "root".

Let's use your examples, and say that your website is located in the
folder
/var/www/sites/somedomain.com/ on the webserver.

then the following is true:

: include("x/z");
tries to include /var/www/sites/somedomain.com/x/z

:include("/x/z");
tries to include /x/z

:include("../x/z");
tries to include /var/www/sites/x/z


Most of the time when I include things, I use the variable
$_SERVER["DOCUMENT_ROOT"] which always points to the root of the
current website.

Let me know if anything needs clarifying.

--
best regards,
Martin Mouritzen.
http://www.siteloom.dk

 

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

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