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 are the delimiters in php?
Define metaphone()?
What is escaping to php?
Is learning php easy?
Write down the code for save an uploaded file in php.
What is the use of 'print' in php?
What is the use of preg_match in php?
What is the use of offset in mysql?
Is key in array php?
What is the latest version of php?
How break and continue while loop in php?
What is inheritance in php with example?