1.2.1141. Static Global Variables Confusion¶
It is recommended to avoid using the same name for a global variable and a static variable.
<?php
function foo() {
$a = 1; // $a is a local variable
global $a; // $a is now a global variable
static $a; // $a is not w static variable
}
?>
1.2.1141.1. Suggestions¶
Avoid using static variables
Avoid using global variables
Avoid using the same name for static and global variables
1.2.1141.2. Specs¶
Short name |
Structures/SGVariablesConfusion |
Rulesets |
|
Exakat since |
2.1.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Features |
global, static |
Available in |