On Nov 11, 2007 6:02 PM, Frank Lopes <[EMAIL PROTECTED]> wrote:

> No takers on this topic?
>
>
> ""Frank Lopes"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >I just started using PHP and got to think...
> >
> > Without getting into the discussion of "best practices", strictly from
>  a
> > performance perspective,
> > what is faster: a function or an include?
> >
> > For example I have a block of text that needs to appear mutliple times
> > throughout the site.
> >
> > Will I be better off creating a function with its contents and then
> later
> > just calling the function or,
> > will it be faster (from an execution perspective) for me to create an
> .inc
> > file that gets included later on?
> >
> > Thanks for the your thoughts.
>

what do you imagine the code might look like in the .inc file?
if you create a variable in global scope in your first script say
$a = 5;

then in another file you intend to include you modify it, again in global
scope,

if($a > 5) {
    $a = 10;
} else {
    $a = 0;
}

well i think that is really messy.
getting to the function idea..  were you planning to put the function in the
same file and thats why you view it as an alternative to including a file?
i would at least create a function and put it in the file you intend to
include.
i imagine it will be a hair slower, but it will be much more organized.

-nathan

Reply via email to