1.2.506. Global Usage

List usage of globals variables, with global keywords or direct access to $GLOBALS.

It is recommended to avoid using global variables, at it makes it very difficult to track changes in values across the whole application.

<?php
$a = 1; /* global scope */

function test()
{
    echo $a; /* reference to local scope variable */
}

test();

?>

See also Variable scope.

1.2.506.1. Specs

Short name

Structures/GlobalUsage

Rulesets

All, Analyze, Appinfo, CE

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Precision

Very high

Features

global

ClearPHP

no-global

Available in

Entreprise Edition, Community Edition, Exakat Cloud