Difference between ...
Notifications
Clear all

Difference between require, include, require_once and include_once

RSS

(@ganesh)
Noble Member
Joined: 1 year ago
Posts: 1362
19/03/2021 11:10 am

Difference between require, include, require_once and include_once?


Quote
(@sathish)
Member Moderator
Joined: 1 year ago
帖子:1391
19/03/2021 11:12 am

There arerequireandinclude_onceas well.

So your question should be...

  1. When should I userequirevs.include?
  2. When should I userequire_oncevs.require

The answer to 1 is describedhere.

The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.

The answer to 2 can be foundhere.

The require_once() statement is identical to require() except PHP will check if the file has already been included, and if so, not include (require) it again.


ReplyQuote
Share:
Baidu