php 函数 utf8_encode 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38337444/
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 01:33:07  来源:igfitidea点击:

Function utf8_encode undefined

php

提问by xil3

I have Ubuntu 16.04 installed, which comes with PHP 7 by default; but I ended up installing PHP 5.6 as well, and I have apache using 5.6.

我安装了 Ubuntu 16.04,它默认随 PHP 7 一起提供;但我最终也安装了 PHP 5.6,并且我有使用 5.6 的 apache。

When I went to run a project of mine, it told me the following:

当我去运行我的一个项目时,它告诉我以下内容:

PHP Fatal error: Call to undefined function utf8_encode()

PHP 致命错误:调用未定义的函数 utf8_encode()

I read through a bunch of posts where others have had this issue, and tried installing different extensions; but nothing has helped.

我阅读了一堆其他人遇到此问题的帖子,并尝试安装不同的扩展;但没有任何帮助。

My understanding, was that that function would be packed with PHP (4,5,7) by default.

我的理解是,默认情况下,该函数将使用 PHP (4,5,7) 打包。

Any ideas?

有任何想法吗?

* Update *

* 更新 *

I did try the following, and it came back false.

我确实尝试了以下方法,但结果是错误的。

var_dump(is_callable('utf8_encode'));

Here are the installed mods/extensions:

以下是已安装的模组/扩展:

[PHP Modules] calendar Core ctype date dom ereg exif fileinfo filter ftp gettext hash iconv json libxml mbstring mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zlib

[PHP 模块] 日历 核心 ctype 日期 dom ereg exif 文件信息过滤器 ftp gettext hash iconv json libxml mbstring mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline 反射会话 shmop SimpleXML 套接字 SPL 标准 sysvmsg sysvsemizer xmlpcreadddrxr OPcache zlib

[Zend Modules] Zend OPcache

[Zend 模块] Zend OPcache

回答by sj59

on ubuntu :

在 Ubuntu 上:

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

回答by xil3

The following fixed it:

以下修复了它:

sudo a2enmod xml2enc

须藤 a2enmod xml2enc

回答by Wendel086

On FreeBSD try this command

在 FreeBSD 上试试这个命令

pkg install php71-tokenizer-7.1.25 php71-zlib-7.1.25

pkg 安装 php71-tokenizer-7.1.25 php71-zlib-7.1.25