PHP7.2 缺少国际扩展名

PHP7.2 missing intl extension

我正在尝试 运行 php 使用来自 intl 扩展的 locale_accept_from_http 功能的应用程序。我的 php 版本是 7.2 并且出现错误:Call to undefined function locale_accept_from_http();

我正在尝试:

1.安装扩展 sudo apt-get install php-intl。 错误是:

Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: php-intl : Depends: php7.1-intl but it is not going to be installed E: Unable to correct problems, you have held broken packages.

2。在 php.ini. 中启用国际扩展 我收到警告:

PHP Warning: PHP Startup: Unable to load dynamic library 'intl'

将此扩展程序与 php7.2 一起使用的正确方法是什么?

正如您的错误中所述,您的软件包已损坏,因此在这种情况下,您应该尝试修复它,可能以下命令会修复它们。

apt update
apt autoremove

一旦你解决了这个问题,如果你还没有添加 ondrej PPA,你可以尝试执行以下命令:

add-apt-repository -y ppa:ondrej/php
apt install php7.2 php7.2-intl