An included helper can keep shared labels in one place.

reusable labels The main file can combine local input with labels loaded from a helper.

Shared Helpers

score
shared_helpers.php
Replay: real traced execution (multi-file project)
<?php
$score = 75;
include __DIR__ . "/score_helper.inc";
if ($score >= 90) {
    $label = $excellentLabel;
} elseif ($score >= 70) {
    $label = $steadyLabel;
} else {
    $label = $practiceLabel;
}

echo "score=" . $score . "\n";
echo "label=" . $label . "\n";
<?php
$score = 55;
include __DIR__ . "/score_helper.inc";
if ($score >= 90) {
    $label = $excellentLabel;
} elseif ($score >= 70) {
    $label = $steadyLabel;
} else {
    $label = $practiceLabel;
}

echo "score=" . $score . "\n";
echo "label=" . $label . "\n";
<?php
$score = 95;
include __DIR__ . "/score_helper.inc";
if ($score >= 90) {
    $label = $excellentLabel;
} elseif ($score >= 70) {
    $label = $steadyLabel;
} else {
    $label = $practiceLabel;
}

echo "score=" . $score . "\n";
echo "label=" . $label . "\n";
  1. $score ← 75, $label ← NULL

    1<?php2$score→ 75 = 75; //@score=55, 953include __DIR__ . "/score_helper.inc";4if ($score >= 90) {5    $label = $excellentLabel;6} elseif ($score >= 70) {7    $label→ NULL = $steadyLabelNULL;8} else {9    $label = $practiceLabel;10}1112echo "score=" . $score75 . "\n";13echo "label=" . $labelNULL . "\n";
    outputscore=75
    label=
  1. $score ← 55, $label ← NULL

    1<?php2$score→ 55 = 55;3include __DIR__ . "/score_helper.inc";4if ($score >= 90) {5    $label = $excellentLabel;6} elseif ($score >= 70) {7    $label = $steadyLabel;8} else {9    $label→ NULL = $practiceLabelNULL;10}1112echo "score=" . $score55 . "\n";13echo "label=" . $labelNULL . "\n";
    outputscore=55
    label=
  1. $score ← 95

    1<?php2$score→ 95 = 95;3include __DIR__ . "/score_helper.inc";4if ($score >= 90) {
  2. $label ← NULL

    3include __DIR__ . "/score_helper.inc";4if ($score95 >= 90) {5    $label→ NULL = $excellentLabelNULL;6} elseif ($score >= 70) {
  3. echo "score=" . $score . " ";

    12echo "score=" . $score95 . "\n";13echo "label=" . $labelNULL . "\n";
    outputscore=95
    label=