What is the best way to dynamically display content on a PHP index page based on URL parameters?
When dynamically displaying content on a PHP index page based on URL parameters, you can use the $_GET superglobal array to retrieve the parameters from the URL and then use conditional statements to determine which content to display. By checking the value of the parameter in the URL, you can customize the content shown on the page accordingly.
<?php
// Retrieve the URL parameter
$param = $_GET['param'];
// Use conditional statements to display content based on the parameter
if ($param == 'option1') {
echo "Content for option 1";
} elseif ($param == 'option2') {
echo "Content for option 2";
} else {
echo "Default content";
}
?>