What is the difference between include and include_once (or require and require_once) in php? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

What is the difference between include and include_once (or require and require_once) in php?

I don't understand, please give me proper answer with an real life example.

15th May 2019, 4:19 PM
Avijit Bakshi
Avijit Bakshi - avatar
1 Respuesta
+ 1
If an error happens, include will give a warning, but the script will still run. Require will give a fatal error and the script will be completely stopped. require_once and include_once are similar with require and include, but they will check whether the file are included or no, so they don't have to include it again
16th May 2019, 4:14 AM
Rainer Affan Regan
Rainer Affan Regan - avatar