Re: how include works?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Arno Kuhl wrote:

I wasn't talking about the difference between require and include but rather
the difference between require and require_once (or include and
include_once). Why doesn't require just work the same way as require_once,
because I can't see the need for require -ing the same file more than once.
Possibly for someone that doesn't understand the purpose of functions, as
Peter suggested, but programming languages don't generally go out of their
way to cater for people who don't understand basic programming concepts.

The _once functions make perfect sense to me. However, if you've not worked on complex PHP systems I can understand why it might seem redundant. Consider that you have a large library of classes. A lot of them will likely depend on other classes in the same collection. So you have a lot of files that include other files. You will more than likely end up with a number of files that include the same files. Without the _once functions this would mean you'd have to manage what you include and where a lot more carefully since you can't declare the same function or class twice. The _once functions take care of tracking which files have been included and so prevent that particular error.

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux