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

Edited by diafol: Pointless and liable to draw spam and rubbish posts

2 Years
Discussion Span
Last Post by peopletrendin

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.


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

Edited by cereal

Votes + Comments
agreed about the title

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.


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

Edited by almostbob

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.