How can external parameters be used to control the output of icons in PHP scripts?

To control the output of icons in PHP scripts using external parameters, you can pass in a parameter through the URL query string and use it to determine which icon to display. This can be achieved by checking the value of the parameter and then outputting the corresponding icon based on that value.

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

// Output the corresponding icon based on the parameter value
if($icon == '1') {
    echo '<img src="icon1.png" alt="Icon 1">';
} elseif($icon == '2') {
    echo '<img src="icon2.png" alt="Icon 2">';
} else {
    echo 'Invalid icon parameter';
}
?>