[MediaWiki-l] When loading extensions is require_once or include_once preferred?

Mark A. Hershberger mah at nichework.com
Thu Nov 6 22:34:21 UTC 2014

Chris Koerner <nobelx at gmail.com> writes:

> From http://www.w3schools.com/php/php_includes.asp

Please don't use W3Schools for PHP information.  Information on any PHP
keyword can be found by typing "http://php.net/KEYWORD" into your
browser's URL bar.

For example, http://php.net/require takes you to a page that clearly
explains the difference between the two:

    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.

> In the general scheme of things, is one a better practice over the other?

On my sites, I like to know as soon as possible if there is a problem.
require() will give an error if a file doesn't exist instead of trying
to continue.  If a site continues to operate with missing files, you'll
probably end up with errors that are harder to diagnose than they need
to be.


Mark A. Hershberger
NicheWork LLC

More information about the MediaWiki-l mailing list