How can PHP be used to dynamically load different pages based on URL parameters?

To dynamically load different pages based on URL parameters in PHP, you can use the $_GET superglobal array to retrieve the parameter value from the URL and then include the corresponding page based on that value. This allows you to create a single PHP script that can handle multiple pages based on the URL parameters.

<?php
$page = isset($_GET['page']) ? $_GET['page'] : 'home';

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