1.2.1631. include_once() Usage

Usage of include_once() and require_once(). Those functions should be avoided for performances reasons.

Try using autoload for loading classes, or use include() or require() and make it possible to include several times the same file without errors.

<?php

// Including a library.
include 'lib/helpers.inc';

// Including a library, and avoiding double inclusion
include_once 'lib/helpers.inc';

?>

1.2.1631.1. Suggestions

  • Avoid using include_once() whenever possible

  • Use autoload() to load classes, and avoid loading them with include

1.2.1631.2. Specs

Short name

Structures/OnceUsage

Rulesets

All, Analyze, Appinfo, CE

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Examples

XOOPS, Tikiwiki

Available in

Entreprise Edition, Community Edition, Exakat Cloud