What is the purpose of the phpinfo() function in PHP and how can it be used to gather information about the server configuration?

The phpinfo() function in PHP is used to display detailed information about the server's PHP configuration, such as PHP version, extensions enabled, server information, and more. This function can be useful for developers to troubleshoot issues related to PHP settings or to gather information about the server environment.

<?php
// Display detailed server information
phpinfo();
?>