How can PHP be used to switch between different pages using parameters like ID?

To switch between different pages using parameters like ID in PHP, you can create a script that checks the value of the ID parameter in the URL and includes the corresponding page based on that value. This can be achieved by using a switch statement or an if-else condition to handle different cases.

<?php
$id = $_GET['id']; // Get the ID parameter from the URL

switch ($id) {
    case 1:
        include 'page1.php';
        break;
    case 2:
        include 'page2.php';
        break;
    case 3:
        include 'page3.php';
        break;
    default:
        include 'error.php'; // Include an error page for invalid IDs
}
?>