View Single Post
  #3  
Old 07-30-2007, 04:57 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 180
saravanan is on a distinguished road
Thumbs up Re: What is the difference between require_once(), require(), include()?

The difference between include() and include_once()
---------------------------------------------------

The only differnece between the two is that include() will always include the file every time it’s called, even if it’s the same file, while include_once() will only include the file once.
example
-------
//Included
include(‘the_file.php’);
//Included again, no point to this
include(‘the_file.php’);
//Included for the first time
include_once(‘the_file.php’);
//Not included again
include_once(‘the_file.php’);

difference between Require_once and include_once
-------------------------------------------------

The require() statement includes and evaluates the specific file.

The require_once() statement includes and evaluates the specified file during the execution of the script.


difference between include and require
-------------------------------------

The include() and require() statements includes and evaluate the specified file.
The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error.
Use require() if you want a missing file to halt processing of the page.

difference between include_once() and require_once()
---------------------------------------------------

include_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
Reply With Quote