Are there more efficient alternatives to using multiple elseif statements for handling different links and includes in PHP?

Using a switch statement can be a more efficient alternative to using multiple elseif statements for handling different links and includes in PHP. Switch statements can make the code more readable and easier to maintain, especially when dealing with multiple conditions.

$page = $_GET['page'];

switch ($page) {
    case 'home':
        include 'home.php';
        break;
    case 'about':
        include 'about.php';
        break;
    case 'contact':
        include 'contact.php';
        break;
    default:
        include '404.php';
}