This is a discussion on What is the difference between require_once(), require(), include()? within the PHP Programming forums, part of the Web Development category; Hi friends, Can any one expalin What is difference between require_once(), require(), include().Becouse above three function usely use to ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| Hi friends, Can any one expalin What is difference between require_once(), require(), include().Becouse above three function usely use to call a file in another file? Thanks devarajan.V |
|
#2
| |||
| |||
| 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. include() produces a Warning while require() results in a Fatal Error. In other words, 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 The require_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the require() statement, with the only difference being that if the code from a file has already been included, it will not be included again |
|
#3
| |||
| |||
| 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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is the difference between require, include and include_once? | amansundar | PHP Programming | 3 | 11-28-2007 09:47 PM |
| Difference between#include< >and#include" " | vigneshgets | C and C++ Programming | 1 | 08-01-2007 11:41 PM |
| Explain the difference between use and require. | vadivelanvaidyanathan | Perl | 1 | 07-30-2007 07:39 AM |
| require_once(), require(), include() | sivakumar | PHP Programming | 1 | 07-16-2007 07:39 AM |
| PHP: include & require, what is different? | montyauto | PHP Programming | 2 | 06-30-2007 01:17 AM |
Our Partners |