require_once(), require(), include()What is difference between them? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 6

require_once(), require(), include()What is difference between them?

how about on this one?

27th Jan 2018, 12:16 PM
John Lloyd V. Dela Vega
John Lloyd V. Dela Vega - avatar
1 ответ
+ 3
The difference are: require(): If it can not find the file that is referenced, the application will throw an error and stop the execution. include(): If it can not find the referenced file it will throw a warning, but the application WILL CONTINUE execution. (sorry for the caps, they are to emphasize) require_once & include_once work in the same way as include() and require() with the difference that they are slower, since the loading of a file is prevented more than once. This prevents the functions and variables from being rewritten and you have an error associated with it. Normally these versions are used only when they are necessary
28th Jan 2018, 5:22 AM
Mickel
Mickel - avatar