How can the print_r() function be helpful in displaying server variables in PHP?

The print_r() function in PHP can be helpful in displaying server variables by providing a structured and easily readable output of the variable contents. This can be useful for debugging purposes or when you need to quickly check the values of server variables such as $_SERVER, $_GET, $_POST, etc.

// Displaying server variables using print_r()
echo '<pre>';
print_r($_SERVER);
echo '</pre>';