What is the exact Diff. between include_once() and
require_once() in PHP?

Answers were Sorted based on User's Feedback



What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

What is the exact Diff. between include_once() and require_once() in PHP?..

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

Post New Answer

More PHP Interview Questions

What is php pathinfo?

0 Answers  


What is the use of mysqli_real_escape_string() function?

0 Answers  


What is session in php w3schools?

0 Answers  


What is the purpose of the '.myd' file extension? What do thes file contain?

0 Answers  


Does mysql need php?

0 Answers  


How can we know that a session is started or not?

8 Answers  


What is echo and print in php?

0 Answers  


What is the difference between explode and split?

0 Answers  


i got 2 year backs in my MCA,i am 28 year guy, presently learning PHP, can i get the job & on facing the interview wht i will answer out for that?? (experience in as a 1.5yr System analyst after graduation)

0 Answers  


What are soundex() and metaphone() functions in php?

0 Answers  


What is the use of addslashes in php?

0 Answers  


I have two radio button, i click one radio button display one dropdown box, one text field. and then click another radio button display one text field.so any one give me good idea plz.....i used <div id="" style=display:none> but not work..

4 Answers  


Categories