FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Is there any situation where anything other than require_once is better?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
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 Go to previous messageGo to previous message
Leonardo Azpurua is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Syntax for trim charlist?
Next Topic: SNMPv3 for PHP?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 08:53:55 GMT 2024

Total time taken to generate the page: 0.04214 seconds