RE: how include works?

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

 



On Tue, May 30, 2006 2:02 am, Peter Lauri wrote:
> 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)?

Once upon a time, a long time ago...

require would ONLY read and parse the file one time, so whatever was
in there at the first 'require' would get parsed once, and, inside of
a loop, pasted multipel times.

include would read/parse the file on each iteration of a loop.

That got changed in PHP3 or so, because A) nobody understood it, and
B) nobody really used it much anyway.

When it did get chagned, it was decided that 'require' should be more
forceful than 'include' so one should error, and one should warn.

There are DEFINITELY times where include more than once is good.

Suppose you  have the body of a <TR><TD>...</TD></TR> in an include
file, and want to include it many times, with different values.

-- 
Like Music?
http://l-i-e.com/artists.htm

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