IT Community - Software Programming, Web Development and Technical Support

What is the difference between require, include and include_once?

This is a discussion on What is the difference between require, include and include_once? within the PHP Programming forums, part of the Web Development category; Hi there.. what's the difference between require, include and include_once?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 11-16-2007, 09:46 PM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 319
amansundar is on a distinguished road
Question What is the difference between require, include and include_once?

Hi there..

what's the difference between require, include and include_once?
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 11-18-2007, 01:01 AM
Naseema Naseema is offline
D-Web Trainee
 
Join Date: Mar 2007
Posts: 11
Naseema is on a distinguished road
Default Re: What is the difference between require, include and include_once?

require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, don't hesitate to use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well.

The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once
__________________
Nasee
True Faith never Fails
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 11-19-2007, 08:44 PM
KiruthikaSambandam KiruthikaSambandam is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 328
KiruthikaSambandam is on a distinguished road
Default Re: What is the difference between require, include and include_once?

Difference between require, include and include_once?

include will include the file, and should it fail, keep running the script.

require will include the file, and should it fail, the script will stop.

include_once and require_once are even more handy if you write scripts that run and include each other, because including() a file more than once will generate errors, but include_once() will only include the file once, regardless of how many times it is called.

ThankQ
KiruthikaSambandam
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 11-28-2007, 08:47 PM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 190
leoraja8 is on a distinguished road
Red face Re: What is the difference between require, include and include_once?

Hi,

require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.

But require() and include() will do it as many times they are asked to do.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between#include< >and#include" " vigneshgets C and C++ Programming 1 08-01-2007 10:41 PM
Explain the difference between use and require. vadivelanvaidyanathan Perl 1 07-30-2007 06:39 AM
What is the difference between require_once(), require(), include()? devarajan.v PHP Programming 2 07-30-2007 04:57 AM
require_once(), require(), include() sivakumar PHP Programming 1 07-16-2007 06:39 AM
PHP: include &amp; require, what is different? montyauto PHP Programming 2 06-30-2007 12:17 AM


All times are GMT -7. The time now is 01:01 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0