What is the exact Diff. between include_once() and
require_once() in PHP?
Answers were Sorted based on User's Feedback
Answer / arvind pippal
. 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.
include_once() should be used in cases where the same file
might be included and evaluatedmore than once during a
particularexecution 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.
require_once() should be used in cases where the same file
might be included and evaluatedmore 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.
Is This Answer Correct ? | 50 Yes | 12 No |
Answer / devendrarjadav
If the file specified with include_once() is not exist then
system displays warning where in the case of require_once()
system displays Fatal error in the client browsers window.
Is This Answer Correct ? | 51 Yes | 27 No |
Answer / umapathi
include_once -it file is not exist it displays warning
message
in case of require_once-if the file is not exist it
displays fatal error
Is This Answer Correct ? | 34 Yes | 18 No |
Answer / rahul anand
when we use require_once then if the file is not existed
then it will show the fetal error and will not execute the
instruction written under the require_once function. In the
case of include_once() if the file does not exist then it
will show the error message and also show the statements
written under the include_once function.
Is This Answer Correct ? | 16 Yes | 11 No |
Answer / vineet kumar saini
1.include() includes a file in memory no matter if it has
already been loaded
2.include_once() includes a file in memory only if it has
not been loaded already
3.require() includes a file in memory no matter if it has
already been loaded. if the file cannot be loaded, the
script is aborted
4.require_once() does the same as require(), but only if the
file hasn't been included yet. if the file's already in
memory, it has no effect.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / basha
include_once -it file is not exist it displays warning
message and continue the program
in case of require_once-if the file is not exist it
displays fatal error and terminate the prgram
Is This Answer Correct ? | 21 Yes | 21 No |
Answer / senthil
in include_once display the warning message if the
containing file is not exist but require_once function
could not diplay the warning message it's a FATAL ERRor in
that time ...
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / izhar aazmi
Include => Include the said file during execution...
Require => Require the said file for the execution...
As in english "require" mandatory inclusion is expected and
hence, on failure execution shall halt with fatal error...
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kedar haldikar
If the file specified with include_once() is not exist then
system displays warning where in the case of require_once()
system displays Fatal error in the client browsers window.
Is This Answer Correct ? | 4 Yes | 9 No |
Answer / maish
both include external file accept
there is failer i smajor difference
in inclde give warning after failure and in requre
give fatal error stop execution file
Is This Answer Correct ? | 6 Yes | 13 No |
What is difference between base_url and site_url?
What is different between software and app
How can you declare a constant variable in php?
What difference between require() and require_once()?
What is the best practice for running mysql queries in php? Consider the risk of sql injection.
Is php procedural or oop?
What are php data types?
What are global variables in php?
Is php still used?
what are the basic steps to installation php4+mysql4+phpmyadmin on IIS web server?. Pls write the complete steps.
How do sessions work in php?
How to track no of user logged in?