Re: how include works?

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

 



On 5/30/06, Arno Kuhl <akuhl@xxxxxxxxxxxx> wrote:
-----Original Message-----
From: Richard Lynch [mailto:ceo@xxxxxxxxx]
Sent: 30 May 2006 06:11
To: Mindaugas L
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  how include works?


On Tue, May 23, 2006 6:19 pm, Mindaugas L wrote:
> can anybody explain how require works, and what's the difference
> between
> _once and regular? What's going on when php file is processed? In
> manual is
> written just, that it's readed once if include_once. What does to mean
> "readed"? Thank You

require and include both basically work EXACTLY as if you
copied/pasted the file into your source code, except that you are
"out" of PHP mode in the included file.

Adding _once means that PHP will ignore the statement if you have
already included or required that file anywhere else in your script
previously.

--

I understand the difference well enough, but I've never really understood
the reason for having both. Is it to help find errors in sloppy coding, or
is there a case where including a file more than once is desirable (and
won't cause an error)?

There was more of a difference earlier on.

On http://www.php.net/manual/en/function.require.php:

Note:  Prior to PHP 4.0.2, the following applies: require()  will
always attempt to read the target file, even if the line it's on never
executes.

Now it behaves the same way except for the failure method (require is
fatal, include is not).

--
Postgresql & php tutorials
http://www.designmagick.com/

--
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