What are the differences between require and include,
include_once?

Answers were Sorted based on User's Feedback



What are the differences between require and include, include_once?..

Answer / sri harsha

include();--> include the file, but in case of file missing
throws a warning and continues execution of code of next line.

require();--> require also includes the file but in case of
file missing throws an fatal error and stop the execution of
the code of next line.

include_once();-->if same file was included first it will
not include the file another time.

Is This Answer Correct ?    46 Yes 1 No

What are the differences between require and include, include_once?..

Answer / tina

require - including a file/page ,if file doesn't exist,then
it gives error and doesn't execute.

include-including a file/page,if file doesn't exit,then it
gives warning and begin to execute.

include_once-including file/page, if it didn't been already
included,it includes else it won't.

Is This Answer Correct ?    41 Yes 3 No

What are the differences between require and include, include_once?..

Answer / ashwini

All three include(),include_once() and require() are used to
an include file into the current page.

If the file is not present, require(), calls a fatal error,
while in include() does not.

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. It does not
call a fatal error if file not exists. require_once() does
the same as include_once(), but it calls a fatal error if
file not exists.

Is This Answer Correct ?    5 Yes 1 No

Post New Answer

More PHP Interview Questions

What is magic quotes?

0 Answers  


How can you submit a form without a submit button?

0 Answers  


How stop the execution of a php scrip?

0 Answers  


How to get path of php.ini with a php script?

1 Answers  


PHP serverside scripting language or client side scripting language>

8 Answers  






How can we find the number of rows in a result set using PHP?

4 Answers  


What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?

1 Answers  


What is cakephp framework?

0 Answers  


What is php crud api?

0 Answers  


What is the default session time in php?

0 Answers  


What is the meaning of curl , which is used while connecting with pay pal? and how it works?

2 Answers  


What is the difference between Reply-to and Return-path in the headers of a mail function?

2 Answers  


Categories