What are some best practices for structuring PHP code to handle multiple design options without resetting to default settings?

When handling multiple design options in PHP without resetting to default settings, it is best to use a configuration file or database to store the chosen design options. This way, the settings can be easily retrieved and applied throughout the codebase without the need to reset to defaults. By separating the design options from the code logic, it allows for easier maintenance and customization.

// Configuration file (config.php)
$designOptions = [
    'theme' => 'light',
    'font_size' => 'medium',
    'layout' => 'full-width',
];

// Function to retrieve design options
function getDesignOption($option) {
    global $designOptions;
    return $designOptions[$option];
}

// Example of how to use the design options
$theme = getDesignOption('theme');
$font_size = getDesignOption('font_size');
$layout = getDesignOption('layout');

echo "Theme: $theme, Font Size: $font_size, Layout: $layout";