I can't understand what is different between require and include 😑 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I can't understand what is different between require and include 😑

6th Nov 2015, 2:45 AM
heet makwana
heet makwana - avatar
5 Answers
+ 4
with include you have to write every time that include this page include this header file etc. but with require is used for the required file without which your script will not run
15th Nov 2015, 10:31 AM
Spirited wolf
+ 1
The key difference between require() and include() is that if you require() a file that can't be loaded (eg if it isn't there) then it generates a fatal error which will halt the execution of the page completely, and no more output will be generated. On the other hand, if you include() a file that can't be loaded, then this will merely generate a warning and continue building the page
21st Apr 2016, 2:39 PM
Ibrahim Otieno
Ibrahim Otieno - avatar
- 1
u should use include for including files that aren't so important, like the text fields we need to fill when opening a new email id. some fields are required and some are optional. optionals are created using require and the rest are created using require.
4th Dec 2015, 8:29 AM
Samiullah chowdhury
Samiullah chowdhury - avatar
- 1
here is a very ..simple ...in the include function... if your add file not exiest so your result is display .main page + warning and if u use require so the result is only warning it gives only error... understood
11th Jan 2016, 5:53 AM
Krishn Kanhaiya Garg
Krishn Kanhaiya Garg - avatar
- 1
the different is the way to handle error.
1st Jul 2016, 4:26 PM
Maksum Rifai
Maksum Rifai - avatar