What are the diffraction between include and require? Which is good to use? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What are the diffraction between include and require? Which is good to use?

20th Oct 2016, 2:38 PM
dhiral thakkar
dhiral thakkar - avatar
2 Answers
+ 2
required will give an error if the file is not found. it is good to use if the file contains core functions. there is also required_once and include_once for no duplication of imports. hope it helps ^.^
29th Oct 2016, 4:02 PM
Nicolas Dussault-Pilon
Nicolas Dussault-Pilon - avatar
+ 1
If the file is not very important to run your php script, you should use include and if the file is very important ( like file that has functions for validation) in order to run your php script you should use require_once() .
26th Dec 2016, 12:23 PM
Raniket Ram
Raniket Ram - avatar