php - 未捕获的错误:找不到类“SimpleXMLElement”
问题描述
SimpleXMLElement 不起作用!
检查 php -v:
PHP 7.4.8 (cli) (built: Jul 13 2020 16:45:28) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies
php -m:
php -m
[PHP Modules]
...
SimpleXML
..
xml
xmlreader
xmlwriter
xsl
...
我使用 PHP 7.2,安装 php-xml、php-simplexml 等。
日志:
PHP Fatal error: Uncaught Error: Class 'SimpleXMLElement' not found in /var/www/html/inc/functions.php:828
php:
$myCurl = curl_init();
curl_setopt_array($myCurl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(array($body))
));
$response = curl_exec($myCurl);
curl_close($myCurl);
$robo_response = new SimpleXMLElement($response);
解决方案
在我的 Ubuntu 上启用了 PHP7.0。需要 PHP 7.4
sudo a2dismod php7.0
sudo a2enmod php7.4
sudo service apache2 restart
谢谢大家的帮助。
推荐阅读
- c - 多文件c项目中的函数声明问题
- r - 如何将复杂的宽表转换为长表
- javascript - JavaScript/CRM 问题:需要帮助根据文本字段中显示的内容设置过滤选项
- http - 无法启动 Alice HTTP Inspector。请将 NavigatorKey 添加到您的应用程序
- javascript - 如何处理冻结浏览器的长时间加载 Plotly 绘图?
- python - python的Systemd服务没有在文件中写入数据
- linux - Apache LockFile 问题
- firebase - 如何调用应用程序在颤动中运行的功能 ASA?
- botframework - 从 1:1 对话机器人框架消息扩展中检索成员电子邮件
- java - Java 在从 Oracle DB 12c 获取值时将特殊字符转换为 HTML5 实体