Hi,

What is the difference between include() and reqiured() in php.

Recommended Answers

All 5 Replies

From require documentation:

require is identical to include except upon failure it will also produce a fatal E_COMPILE_ERROR level error. In other words, it will halt the script whereas include only emits a warning (E_WARNING) which allows the script to continue.

Links:

Please, next time write a more appropriate title, it will help users to find their answers.

commented: agreed about the title +15

It is possible to insert the content of one PHP file into another PHP file (before the server executes it), with the include or require statement. The include and require statements are identical, except upon failure: require will produce a fatal error (E_COMPILE_ERROR) and stop the script.

Member Avatar for diafol

Although this OP has posted a valid, yet pointless question in this forum. A similarly pointless question has appeared elsewhere. This question has been asked many times before and this has been answered adequately by cereal here. So let's leave it there.

main difference in the OP
include() is spelled properly, and will work
reqiured() is not, and won't

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.