How can PHP be used to display different content based on the URL parameters?

To display different content based on URL parameters in PHP, you can use the $_GET superglobal array to retrieve the parameter values from the URL and then use conditional statements to determine which content to display based on those values.

<?php
// Retrieve the value of the 'page' parameter from the URL
$page = $_GET['page'];

// Use a switch statement to display different content based on the 'page' parameter
switch ($page) {
    case 'home':
        echo "Welcome to the homepage!";
        break;
    case 'about':
        echo "Learn more about us here.";
        break;
    case 'contact':
        echo "Contact us for more information.";
        break;
    default:
        echo "Page not found.";
}
?>