$required_php_version = '7.2'; if (version_compare(PHP_VERSION, $required_php_version) < 0) { echo "Error: PHP version $required_php_version or higher is required"; exit; }
$required_extensions = array('pdo_mysql', 'openssl'); foreach ($required_extensions as $extension) { if (!extension_loaded($extension)) { echo "Error: Extension $extension is required"; exit; } }In this example, the code checks if the required extensions (pdo_mysql and openssl) are installed and enabled on the system. If any of the required extensions are not available, an error message is displayed. Package library: PHP Extensions Check (https://github.com/requirements-checker/php-extensions-check)