Reply to Re: require_once() and Subdirectories

Your name:

Reply:


Posted by David T. Ashley on 06/07/07 15:45

"phpCodeHead" <phpcodehead@gmail.com> wrote in message
news:1181229551.203483.302990@p77g2000hsh.googlegroups.com...
> On Jun 7, 9:56 am, "David T. Ashley" <d...@e3ft.com> wrote:
>> Hi,
>>
>> Does require_once() treat "file.inc" and "subdirectory/file.inc" as the
>> same
>> things or different?
>>
>> 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.
>
> Taken directly from the manual.
>
> http://us.php.net/manual/en/function.include.php
>
> Please note that include(), include_once(), require(), and
> require_once() all function the same so far as in reference to your
> question.
>
> " Files for including are first looked in include_path relative to the
> current working directory and then in the directory of the current
> script. E.g. if your include_path is libraries, current working
> directory is /www/, you included include/a.php and there is include
> "b.php" in that file, b.php is first looked in /www/libraries/ and
> then in /www/include/. If filename begins with ./ or ../, it is looked
> only in include_path relative to the current working directory.
>
> When a file is included, the code it contains inherits the variable
> scope of the line on which the include occurs. Any variables available
> at that line in the calling file will be available within the called
> file, from that point forward. However, all functions and classes
> defined in the included file have the global scope. "

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 and how that might interact with
paths.

Thanks, Dave.

[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

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