PHP:获取ICU版本

My production site just provides the old ICU version 4.2.1. Since Yii2 requires Version 49.1 or higher I need to make workarounds in PHP.

How do I get the nersion number of ICU (libicu) which is used by PHP during runtime. Since I have frequent production updates I need to get the version number dynamically in PHP code, e.g. by

$libIcuVersion = ...

The version number is shown in phpinfo.php but the output cannot be used in my code.

You can use this slightly modified method that Yii 2 is using:

function checkPhpExtensionVersion($extensionName)
{
    if (!extension_loaded($extensionName)) {
        return false;
    }
    $extensionVersion = phpversion($extensionName);
    if (empty($extensionVersion)) {
        return false;
    }
    if (strncasecmp($extensionVersion, 'PECL-', 5) === 0) {
        $extensionVersion = substr($extensionVersion, 5);
    }

    return $extensionVersion;
}