You are here: Re: Required files confused between applications on same server « PHP Programming Language « IT news, forums, messages
Re: Required files confused between applications on same server

Posted by Rik on 07/29/07 16:14

On Sun, 29 Jul 2007 18:03:25 +0200, Ray <rod@iol.ie> wrote:

> On Jul 28, 10:40 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
>
>> Both apps asume they know where they are running, which is bad, very
>> bad.
>> No fault/bug in PHP, just careless coding.
>
> Actually, inexperience :-) as I'm (relatively) new to PHP.

Aha, well, a lesson learned :-)


>> Usually I solve this problems bij
>> require(dirname(__FILE__).'/config.php');
>
> My mistake was assuming that require(....) takes the current URL root
> as its starting point - for example, if the app is running at
> http://www.myserver.ie/myapp then require('config.php') would look for
> config.php at http://www.myserver.ie/myapp/config.php.....but you're
> saying that it's actually looked for at the physical filesystem
> location on the server (c:\documents and settings\....etc....
> \config.php) - am I correct?
>
> The other thing that I can't understand is why one app should
> interfere with another in this way - is this an IIS thing, or can it
> happen on Apache also?

On both. PHP has a 'current working dir', the files are searched in the
include_path, wich usually holds '.' (the current working directory), and
possibly others. This current working dir is not the directory of the file
that asks for an include/require, but usually where the process started.
It can be quite confusing when including several files, so to check what
the dir is you can use get_cwd();
--
Rik Wasmus

 

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

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