How can multiple pages be handled using $_GET in PHP?

When handling multiple pages using $_GET in PHP, you can pass a parameter in the URL to determine which page to display. This parameter can be accessed using $_GET['page'] and then used to include the corresponding page content. By dynamically loading different pages based on the value of the 'page' parameter, you can create a multi-page website using a single PHP file.

<?php
// Check if the 'page' parameter is set in the URL
if(isset($_GET['page'])) {
    $page = $_GET['page'];
    // Include the corresponding page content based on the 'page' parameter
    switch($page) {
        case 'home':
            include 'home.php';
            break;
        case 'about':
            include 'about.php';
            break;
        case 'contact':
            include 'contact.php';
            break;
        default:
            include 'error.php';
            break;
    }
} else {
    // Default to home page if 'page' parameter is not set
    include 'home.php';
}
?>