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

i want to need upload above 100mb file,i was successfully upload 75mb using .htaccess file ,but i can put 101mb file,it was not upload..please give some tips..local server its work perfectly but online it doesn't work.. .htaccess file details AddHandler application/x-httpd-php .php php_value post_max_size 200M php_value upload_max_filesize 200M php_value memory_limit 300M php_value output_buffering on php_value max_execution_time 259200 php_value max_input_time 259200 php_value session.cookie_lifetime 0 php_value session.gc_maxlifetime 259200 php_value default_socket_timeout 259200

1 Answers  


how to upload 100mb file using .htaccess..

2 Answers  


Is salary fixed or variable cost?

0 Answers  


What is inheritance in php? How many types of inheritance supports php?

0 Answers  


What is class extend in php?

0 Answers  






What is php date function?

0 Answers  


What is a query give example?

0 Answers  


Does php class need constructor?

0 Answers  


How do you check if a variable has been set in php?

0 Answers  


This is regarding file uploading. 1. Who will be the owner of the uploaded file ? 2. What permission you will give for an uploaded file ? 3. What is mean by user, group and others and what kind of permission you will give for each user and explain the reason?

1 Answers   IBM,


What is basename php?

0 Answers  


What is the super method?

0 Answers  


Categories