How can you use phpinfo() to gather information about the server environment in PHP?

To gather information about the server environment in PHP, you can use the phpinfo() function. This function outputs a large amount of information about the current PHP configuration, including PHP version, server information, and environment variables. You can use this information to troubleshoot issues or optimize your PHP scripts.

<?php
// Output all information about the PHP environment
phpinfo();
?>