PHP:获取ICU版本 [英] PHP: Get Version of ICU

查看:122
本文介绍了PHP:获取ICU版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的生产站点仅提供旧的ICU版本4.2.1.由于Yii2需要版本49.1或更高版本,因此我需要在PHP中进行变通.

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.

如何获取运行时PHP使用的ICU(libicu)的版本号.由于我经常进行生产更新,因此需要在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 = ...

版本号显示在phpinfo.php中,但是输出无法在我的代码中使用.

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

推荐答案

Symfony/Intl Symfony\Component\Intl::getIcuVersion()中完成.

try {
    $reflector = new \ReflectionExtension('intl');
    ob_start();
    $reflector->info();
    $output = strip_tags(ob_get_clean());
    preg_match('/^ICU version (?:=>)?(.*)$/m', $output, $matches);
    $icuVersion = trim($matches[1]);
} catch (\ReflectionException $e) {
    $icuVersion = null;
}

这篇关于PHP:获取ICU版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆