What is the recommended method to implement a template switch in PHP?

When implementing a template switch in PHP, the recommended method is to use a switch statement to determine which template to include based on a specific condition or variable. This allows for cleaner and more organized code compared to using multiple if-else statements.

$template = 'default'; // Default template

switch ($template) {
    case 'template1':
        include 'template1.php';
        break;
    case 'template2':
        include 'template2.php';
        break;
    case 'template3':
        include 'template3.php';
        break;
    default:
        include 'default.php';
        break;
}