DEV Community

Cover image for Difference between include, require, include_once and require_once in PHP

Difference between include, require, include_once and require_once in PHP

Amine Saissi Hassani on August 02, 2021

First of all we should know what is the difference and similarity between include() and require(), include() and require() are used to include othe...
Collapse
 
samuelroland profile image
Samuel Roland

It's worth mentioning that the error you are talking about is that the file that we try to import is not found. include() can cause crash too for other reasons (the included php script contains functions already declared at the last inclusion for ex -> for this reason we use *_once() options).

Collapse
 
aminesaissihassani profile image
Amine Saissi Hassani

oh thank you for your feedback I really appreciate it, I will edit this post and add more examples and explanation!
Thank you!

Collapse
 
samuelroland profile image
Samuel Roland

But thanks for this little explanation !

Collapse
 
abdelhalimlakfifi profile image
abdelhalim LAKFIFI

Thank you that's amazing

Collapse
 
aminesaissihassani profile image
Amine Saissi Hassani

Thank you!

Collapse
 
aabiseverywhere profile image
Aabishkar Wagle

Thanks, very short nice and to the point.

Collapse
 
aminesaissihassani profile image
Amine Saissi Hassani

Thank you!

Collapse
 
yoshida profile image
Masao Yoshida

Your introduction was short and clear.
Thanks.

Collapse
 
aminesaissihassani profile image
Amine Saissi Hassani

Thank you!

Collapse
 
nnafzaoui profile image
nnafzaoui

Nice, thanks keep writing

Collapse
 
aminesaissihassani profile image
Amine Saissi Hassani • Edited

Thank you, I'll keep writing!

Collapse
 
soumiakab profile image
KABRANE SOUMIA

good

Collapse
 
aminesaissihassani profile image
Amine Saissi Hassani

Thanks!

Collapse
 
wporta06 profile image
wporta06

This is really helpful, thank you!

Collapse
 
aminesaissihassani profile image
Amine Saissi Hassani

Thank you!