调用未定义的函数simplexml_load_file()

问题描述 投票:3回答:1

我在我的ubuntu服务器上运行了php 7.0。

php -m命令说:


[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mcrypt
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
xmlwriter
xsl
Zend OPcache
zip
zlib

但是当我运行我的网站时,它的日志显示“PHP致命错误:调用未定义的函数simplexml_load_file()”

ubuntu simplexml php-7
1个回答
2
投票

我遇到过同样的问题。我通过安装php7.2-xml来修复它:

$ apt-get install php7.2-xml

之后,SimpleXML被php -m列出:

$ php -m | grep -i simple
SimpleXML

0
投票

我正在使用ubuntu 18.04。当我在模块列表中检查SimpleXML时,它与您的相同。

然后我检查我的phpinfo(),它说它是从不同的php版本拉,而不是与php cli相同。

要检查php cli版本,我运行php -v enter image description here

为了检查phpinfo(),我把函数放在我脚本的index.php的顶部。 enter image description here

在确认我的php cli版本与phpinfo中的版本不同之后,

我只是运行这个2命令

sudo a2dismod php7.0

sudo a2enmod php7.3

然后重启我的apache

sudo systemctl重启apache2

之后,我再次测试我的phpinfo()

现在它正在运作。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.