Reply to Re: require_once() and Subdirectories

Your name:

Reply:


Posted by Rik on 06/07/07 15:14

On Thu, 07 Jun 2007 16:56:34 +0200, David T. Ashley <dta@e3ft.com> wrote:

> Hi,
>
> Does require_once() treat "file.inc" and "subdirectory/file.inc" as the
> same
> things or different?

Different, obviously, it searches another directory for the file instead
of the current working directory.

> The reason for my question is that I'd like to organize my PHP library
> into
> subdirectories, and if I accidentally have a naming collision, I'm
> curious
> how require_once() will behave.

It recognizes the exact file you use (how else could PHP actually open the
included/required file?). So no matter how much files are named
'class.php' or 'index.php', each will be recognised as different in their
respective directory.

So to answer the real question: you can divide your library into different
directories all you like, files in different directories with the same
name do not bother the include(_once())/require(_once()) functions.

The only caveat is the if you're used to working with (and are depending
on) a standard include_dir, you might get some unexpected results
--
Rik Wasmus

[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

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