Re: Is there any situation where anything other than require_once is better? [message #171929 is a reply to message #171927] |
Fri, 21 January 2011 17:47 |
Leonardo Azpurua
Messages: 46 Registered: December 2010
Karma:
|
Member |
|
|
"sheldonlg" <sheldonlg(at)thevillages(dot)net> wrote
>
> There is a use for require rather than require_once. Suppose, for
> example, that you have a drop-down select list of the year (or
> anything else). You might very well want to create an include file
> for all the options in that list. If you have more than one date
> control (or any other type of control that needs the same content),
> then it becomes a simple and consistent matter to just define the
> dropdown and do a "require" of the contents list file. In this case
> a "require_once" would not be appropriate since it needs to be used
> more than once on the page.
Yes. One might use include to insert a sequence of code in a
particular point of the output sequence.
Wouldn't in that case be better to write a function that outputs the
required HTML and then call that function where it is needed? Or else,
in the required file assign the desired string to a var and then
echoing the var? It seems cleaner to me.
Thank you very much. I hadn't thought about "include/require" in those
terms.
--
Leonardo
|
|
|