How can the PHP function print_r() be used to debug $_GET variables?

When debugging $_GET variables in PHP, the print_r() function can be used to display the contents of the array. This can help identify any issues with the values being passed through the URL parameters. By using print_r($_GET), you can easily see the key-value pairs of the $_GET array and troubleshoot any problems.

// Debugging $_GET variables using print_r()
if(isset($_GET)) {
    echo '<pre>';
    print_r($_GET);
    echo '</pre>';
}