1.2.1160. Static Variables

PHP variables may be static or standard. Static variables survive after the function execution end, and are available at the next function run. They are distinct from globals, which are available application wide, and from static properties, which are tied to a class. Static variables are tied to a function, method, closure <https://www.php.net/`closure>`_ or arrow function.

<?php

function foo() {
    // static variable
    static $count = 0;

    echo ++$count;
}

class bar {
    // This is not a static variable :
    // it is a static property
    static $property = 1;
}

?>

See also Using static variables.

1.2.1160.1. Connex PHP features

1.2.1160.1.1. Specs

Short name

Variables/StaticVariables

Rulesets

All, Appinfo, CE, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Community Edition, Exakat Cloud