This is a discussion on When should I use REQUIRE and when should I use INCLUDE? within the PHP Language forums, part of the PHP Programming Forums category; What is the difference between REQUIRE and INCLUDE and in what circumstances should one be used over the other?...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On 25 Mar 2005 10:50:54 -0800, "erin g" <eringeyer@gmail.com> wrote:
>What is the difference between REQUIRE and INCLUDE and in what >circumstances should one be used over the other? http://uk2.php.net/require http://uk2.php.net/include/ -- Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool |
|
|||
|
"erin g" <eringeyer@gmail.com> wrote in message
news:1111776654.744830.88810@g14g2000cwa.googlegro ups.com... > What is the difference between REQUIRE and INCLUDE and in what > circumstances should one be used over the other? > Not much of a difference really. The fact that we have both is entirely historical. In PHP 3, require's are evaluated as the file is parsed. Code in a require'ed file is linked into the running script even if it's never executed. The following, for example, would throw an fatal error: if(file_exists("idontexists.php3")) { require("idontexists.php3"); } Include's on the other hand occur at runtime, so the above fragment, with include in place of require, would work as intended. Starting with PHP 4, require's occur at runtime too. The only difference remaining between the two is the type of error emitted as others have already explained. I personally use require almost exclusively. |