CRITICAL
Rule Definition
Using variables without testing them for initialization is very risky because it could cause an application crash, as such, this practice should be avoided.
Remediation
Modify the source code to reduce the use of non-tested variables. Instead try to use the the 'isset' (for variables) or 'defined' (for constants) functions.
Violation Code Sample
<?php
$variable = "0";
if($variable){
echo "set";
} else {
echo "Not set";
}
?>
Fixed Code Sample
<?php
if($_GET['id']){
// Id is given, get item
} else {
// No id is given, list all items
}
?>
Related Technologies
Technical Criterion
Programming Practices - Unexpected Behavior
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.