php 从 php7 中删除了 utf8_(en|de) 代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35701730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:33:08  来源:igfitidea点击:

utf8_(en|de)code removed from php7?

phputf-8mbstring

提问by paolo

I recently switched to PHP 7 on my development server, which has worked just fine - until now.

我最近在我的开发服务器上切换到 PHP 7,它运行得很好 - 直到现在。

Since I updated to PHP 7.0.3-10+deb.sury.org~trusty+1(earlier today), the utf8_decodeand utf8_encodefunctions are no longer accessible. They were, however, in previous versions of PHP7. When called, a fatal error is raised.

自从我更新到PHP 7.0.3-10+deb.sury.org~trusty+1(今天早些时候)以来,utf8_decodeutf8_encode功能不再可用。然而,它们在早期版本的 PHP7 中。调用时,会引发致命错误。

I read that these functions are provided by the mbstringextension, which I checked with var_dump(extension_loaded('mbstring'));is loaded.

我读到这些功能是由mbstring我检查的扩展程序提供的var_dump(extension_loaded('mbstring'));

How can I get the above functions to work again?

我怎样才能让上述功能再次工作?

回答by Vladimir Korshunov

I had the same problem. Just install php7.0-xmlpackage. Ubuntu 16.04:

我有同样的问题。安装php7.0-xml包就行了。Ubuntu 16.04:

sudo apt-get install php7.0-xml

Edit: Restart apache2to load the new package.

编辑:重新启动 apache2以加载新包。

回答by Thomas Weller

On Ubuntu, you got the following message during the upgrade of PHP7:

在 Ubuntu 上,您在升级 PHP7 期间收到以下消息:

php7.0 (7.0.3-6) unstable; urgency=medium

  * Several extensions have been split into separate extension packages:
   - php-dba - Database (dbm-style) Abstraction Layer
   - php-mbstring - Multibyte String
   - php-soap - SOAP
   - php-xml - DOM, SimpleXML, WDDX, XML, XMLReader and XMLWriter
   - php-zip - Zip
  * The new packages are not installed automatically, so you will need to
    install them by hand, if you use the functions in those modules.
  * Most modules that have been builtin before are now included in
    php7.0-common package and they are enabled by default for your
    convenience.  You can disable unneede modules via phpdismod tool.

 -- Ond?ej Sury <[email protected]>  Mon, 22 Feb 2016 12:37:09 +0100

so it's one of those packages that's causing the problem. In this case, it's php-xml.

所以它是导致问题的软件包之一。在这种情况下,它是php-xml.

Note the

请注意

The new packages are not installed automatically

新软件包不会自动安装

You can fix that by

你可以通过

sudo apt-get install php-xml
sudo apache2ctl graceful

回答by Guenther Schmitz

As the top voted answer did not work for me i found yet another package for php7 which (obvious by its name) fixed it for me

由于最高投票的答案对我不起作用,我发现了另一个 php7 包(从名称上看)为我修复了它

sudo apt-get install php7.0-mbstring

回答by R?mulo Z. C. Cunha

In Ubuntu 16.04 LTS, with php 5.6, try:

在 Ubuntu 16.04 LTS 中,使用 php 5.6,尝试:

sudo apt-get install php5.6-xml
sudo service apache2 restart

回答by Waqar Alamgir

If you are on CentOS, following command should work:

如果你在 CentOS 上,下面的命令应该可以工作:

yum install php-xml

回答by DevLoots

The utf8_decode and utf8_encode functions are accessible in php 7:

utf8_decode 和 utf8_encode 函数可在 php 7 中访问:

function.utf8-encode - manual - php

function.utf8-encode - 手册 - php

This is because the php-xml package is missing in your php installation.

这是因为您的 php 安装中缺少 php-xml 包。

If your server is running Mandrake, enter "urpmi php-xml".

如果您的服务器正在运行 Mandrake,请输入“urpmi php-xml”。

If your server is running EASYPHP on Windows, click on the EASYPHP logo to activate the php-xml module.

如果您的服务器在 Windows 上运行 EASYPHP,请单击 EASYPHP 徽标以激活 php-xml 模块。

On debian or ubuntu try :

在 debian 或 ubuntu 上尝试:

apt-get install php7.0-xmlrpc

回答by jk - Reinstate Monica

I encountered the same problem and for me,

我遇到了同样的问题,对我来说,

sudo apt-get install php-patchwork-utf8

and restarting the apache2 server solved the problem (on Ubuntu 16.04 LTS).

并重新启动 apache2 服务器解决了问题(在 Ubuntu 16.04 LTS 上)。