|
Posted by David T. Ashley on 06/07/07 15:45
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.ttj4mwavqnv3q9@metallium...
> 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
Thanks for your reply.
My question was subtly different.
I have no doubt that require_once() will open and include the correct file.
I was concerned about it possibly believing that "/dir1/file.inc" had been
included when it was "/dir2/file.inc". In other words, I was concerned
about the "once" part of it and how it remembers what has already been
included.
My question was about the "once" part of it.
Thanks, Dave.
[Back to original message]
|