Re: Include files
| From: | David Eisenhart | Date: | Wed, 26 Feb 2003 14:14:06 +0000 |
| Subject: | Re: Include files | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137232@lists.php.net to get a copy of this message | ||
if require is used to include the 'same file', say, twice that file will be
loaded twice. This can of course cause errors (such as resulting from the
redefinition of functions within this file). In contrast the require_once
construct will only load a file 'once' irrespective of the number of times
it is subsequently called to do so (thereby preventing such errors arising).
I would imagine (but am not certain) that there may be a slight speed
penalty in using require_once as opposed to require.
David
"Jinky Otacan Cocalon" <jcocalon@ntsp.nec.co.jp> wrote in message
news:3E5C1F18.6070601@hq.ntsp.nec.co.jp...
> the problem was solved by creating an include file and using using
> require() method
>
> i was just wondering what are the advantages and disadvantages of using
> require_once() instead of require()?
>
> thanx =)
>
>
>
>
> John W. Holmes wrote:
> >>How do I include external library files in PHP???
> >>I would like to put the lines that are repeated in each php files, in
> >
> > a
> >
> >>separate file.
> >>e.g.
> >><?php
> >>$db_host = "localhost";
> >>$db_port = "3306";
> >>$db_name = "test";
> >>...
> >>?>
> >
> >
> > Just throw caution to the wind and try the include() function!!!! I'm
> > not responsible for the consequences!!! Do not blame me if your file is
> > included!!
> >
> > ---John W. Holmes...
> >
> > PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> > today. http://www.phparch.com/
> >
> >
> >
>
> --
>
> "Gravity can't be held responsible for people falling in love."
>