What are some best practices for checking server configurations and versions when troubleshooting PHP-related issues on a website?

When troubleshooting PHP-related issues on a website, it is important to check the server configurations and versions to ensure compatibility with the PHP code being used. One best practice is to verify that the PHP version being used is supported by the server and that all necessary PHP extensions are enabled. Additionally, checking the server's error logs can provide valuable information about any issues that may be occurring.

<?php
// Check PHP version
if (version_compare(PHP_VERSION, '7.0.0') < 0) {
    echo "PHP version 7.0.0 or higher is required";
}

// Check for required PHP extensions
$required_extensions = ['mysqli', 'gd', 'curl'];
foreach ($required_extensions as $extension) {
    if (!extension_loaded($extension)) {
        echo "$extension extension is not enabled";
    }
}

// Check server error logs
$error_log = ini_get('error_log');
if (!empty($error_log)) {
    echo "Server error log location: $error_log";
}
?>