How can PHP include files in a way that allows for dynamic content based on URL parameters?

To include files in PHP based on URL parameters, you can use the $_GET superglobal array to retrieve the parameters and then dynamically include the corresponding file. This allows for dynamic content based on the parameters passed in the URL.

<?php
// Retrieve the URL parameter
$param = $_GET['param'];

// Include the corresponding file based on the parameter
if ($param == 'page1') {
    include 'page1.php';
} elseif ($param == 'page2') {
    include 'page2.php';
} else {
    include 'default.php';
}
?>