Include and Require
Shared Helpers
An included helper can keep shared labels in one place.
Shared Helpers
shared_helpers.php
<?php
$score = ;
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 = ;
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 = ;
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";
reusable labels
The main file can combine local input with labels loaded from a helper.