chhaya
chhaya

Reputation: 719

What is the difference between include and required file in php?

In php file ofthe we use include and require a file. I think both are used for attaching an external file but when we use include and when require?

Upvotes: 0

Views: 391

Answers (1)

cdhowie
cdhowie

Reputation: 169018

require() will cause a fatal error if the file cannot be found, therefore terminating the script. include() will only emit a warning, and the script will continue to run. So you should use require() when you are including a library or something that you need for your script, and include() when the include is optional.

In practice, I have only ever used require().

Upvotes: 1

Related Questions