How can different styles be applied to a PHP-based website using templates?

To apply different styles to a PHP-based website using templates, you can create separate CSS files for each style and include them in your template files based on some condition. This can be achieved by passing a style parameter to your template file and using it to dynamically include the appropriate CSS file.

<?php
// Define the style parameter
$style = 'style1';

// Include the appropriate CSS file based on the style parameter
if ($style === 'style1') {
    echo '<link rel="stylesheet" type="text/css" href="style1.css">';
} elseif ($style === 'style2') {
    echo '<link rel="stylesheet" type="text/css" href="style2.css">';
} else {
    echo '<link rel="stylesheet" type="text/css" href="default.css">';
}
?>