|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
PHP
DETAILS
Question: What is difference between require_once(), require(), include(). Becouse above three function usely use to call a file in another file.
Answer: Difference between require() and require_once(): require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.
Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING.
There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().
|
|
|
Category |
PHP Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 8899 users |
Added on |
7/19/2011 |
Views |
72407 |
Rate it! |
|
|
Question:
What is difference between require_once(), require(), include(). Becouse above three function usely use to call a file in another file.
Answer:
Difference between require() and require_once(): require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.
Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING.
There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once(). Source: CoolInterview.com
There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once(). Source: CoolInterview.com
Answered by: Sandeep Mehra | Date: 4/9/2009
| Contact Sandeep Mehra
require() stop the further execution of the program as soon as it encounters and error.
include() continues the execution of the program until the last statement even when it encounters a error in between. Source: CoolInterview.com
Answered by: shashidhar | Date: 10/6/2009
| Contact shashidhar
include() --------- It includes a spcified file. It will produce a a warning if it fail to find the file and execute the remaining scripts
require ----------- It includes a spcified file. It will produce a a fatal error if it fail to find the file and stops the ececution
include_once() ------------------- It includes a spcified file. a file has already been included, it will not be included again. It will produce a a warning if it fail to find yhe file and execute the remaining scripts.
require_once() ----------- It includes a spcified file. a file has already been included, it will not be included again. It will produce a a fatal error if it fail to find the file and stops the ececution Source: CoolInterview.com
Answered by: Subash | Date: 4/11/2010
| Contact Subash
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
If you have to work with dates in the following format: "Tuesday, February 14, 2006 @ 10:39 am", how can you convert them to another format, that is easier to use?
|
View Answer
|
|
How do we know browser properties?
|
View Answer
|
|
How i will check that user is, logged in or not. i want to make it a function and i want to use in each page and after login i want to go in current page(same page. where i was working)
|
View Answer
|
|
How can i get ip address?
|
View Answer
|
|
What is difference between mysql_connect and mysql_pconnect
|
View Answer
|
|
What is the difference between echo and print statement?
|
View Answer
|
|
How i can make a chat page in php in simple
|
View Answer
|
|
What is difference between mysql_fetch_array(),mysql_fetch_row() and mysql_fetch_object() please insert with example.
|
View Answer
|
|
How can I maintain the count of how many persons have hit my site?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All PHP Interview Questions & Answers - Exam Mode /
Learning Mode
|