When should I use REQUIRE and when should I use INCLUDE?

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


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-25-2005
erin g
 
Posts: n/a
Default When should I use REQUIRE and when should I use INCLUDE?

What is the difference between REQUIRE and INCLUDE and in what
circumstances should one be used over the other?

Reply With Quote
  #2 (permalink)  
Old 03-25-2005
Andy Hassall
 
Posts: n/a
Default Re: When should I use REQUIRE and when should I use INCLUDE?

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
Reply With Quote
  #3 (permalink)  
Old 03-25-2005
frizzle
 
Posts: n/a
Default Re: When should I use REQUIRE and when should I use INCLUDE?

'require' will stop processing if the file can't be included,
'include' will go on...

Reply With Quote
  #4 (permalink)  
Old 03-26-2005
erin g
 
Posts: n/a
Default Re: When should I use REQUIRE and when should I use INCLUDE?

thanks

Reply With Quote
  #5 (permalink)  
Old 03-26-2005
Chung Leong
 
Posts: n/a
Default Re: When should I use REQUIRE and when should I use INCLUDE?

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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0