What potential pitfalls can occur when using if-statements to limit font sizes in PHP and how can they be avoided?

Potential pitfalls when using if-statements to limit font sizes in PHP include not properly handling edge cases, such as when the font size is already at the minimum or maximum limit. To avoid these pitfalls, it's important to include conditions that check for these edge cases and handle them accordingly in the if-statements.

$font_size = 14;

// Limit font size to a minimum of 10 and a maximum of 20
if ($font_size < 10) {
    $font_size = 10;
} elseif ($font_size > 20) {
    $font_size = 20;
}

echo "Font size: " . $font_size;