Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 19, 2019

[This PR is part of a series to introduce code style checking to the repo]

include and require are language constructs, not functions.

With that in mind there are a number of best practices surrounding them:

  • There is no need to use parenthesis and not doing so will be, albeit marginally, faster.
  • Always pass an absolute path for maximum portability.
    Using dirname(__FILE__) instead of __DIR__ to maintain compatibility with PHP 5.2.
  • Use require_once instead of include when the file is required for the rest of the script to be able to function.

`include` and `require` are language constructs, not functions.

With that in mind there are a number of best practices surrounding them:
* There is no need to use parenthesis and not doing so will be, albeit marginally, faster.
* Always pass an absolute path for maximum portability.
    Using `dirname(__FILE__)` instead of `__DIR__` to maintain compatibility with PHP 5.2.
* Use `require_once` instead of `include` when the file is _required_ for the rest of the script to be able to function.
@jrfnl jrfnl added this to the 1.7.1 milestone Sep 19, 2019
@ntwb ntwb merged commit 56286a0 into master Oct 5, 2019
@ntwb ntwb deleted the feature/cs-include-require-review branch October 5, 2019 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants