请问下Function libxml_disable_entity_loader() is deprecated 这个报错是什么原因

来源:13-7 支付系统-下单API开发..

慕圣4442630

2021-05-19

[2021-05-19T17:04:51+08:00][info] namespace[app\lib\pay] file[Weixin.php] line[39] think\exception\ErrorException: Function libxml_disable_entity_loader() is deprecated in /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/lib/pay/weixin/lib/database/WxPayDataBase.php:95
Stack trace:
#0 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/lib/pay/weixin/lib/database/WxPayDataBase.php(95): think\initializer\Error->appError(8192, 'Function libxml...', '/Users/xuchi/De...', 95)
#1 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/lib/pay/weixin/lib/database/WxPayResults.php(107): app\lib\pay\weixin\lib\database\WxPayDataBase->FromXml('<xml><return_co...')
#2 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/lib/pay/weixin/lib/WxPayApi.php(71): app\lib\pay\weixin\lib\database\WxPayResults::Init(Object(app\lib\pay\weixin\lib\WxPayConfig), '<xml><return_co...')
#3 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/lib/pay/weixin/lib/WxPayNativePay.php(68): app\lib\pay\weixin\lib\WxPayApi::unifiedOrder(Object(app\lib\pay\weixin\lib\WxPayConfig), Object(app\lib\pay\weixin\lib\database\WxPayUnifiedOrder))
#4 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/lib/pay/Weixin.php(35): app\lib\pay\weixin\lib\WxPayNativePay->GetPayUrl(Object(app\lib\pay\weixin\lib\database\WxPayUnifiedOrder))
#5 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/business/Pay.php(21): app\lib\pay\Weixin->unifiedOrder(Array)
#6 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/app/controller/Pay.php(50): app\business\Pay->unifiedOrder('hdgame_mall', 'weixin', Array)
#7 [internal function]: app\controller\Pay->unifiedOrder()
#8 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Container.php(343): ReflectionMethod->invokeArgs(Object(app\controller\Pay), Array)
#9 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/route/dispatch/Controller.php(110): think\Container->invokeReflectMethod(Object(app\controller\Pay), Object(ReflectionMethod), Array)
#10 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Pipeline.php(59): think\route\dispatch\Controller->think\route\dispatch\{closure}(Object(app\Request))
#11 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->think\{closure}(Object(app\Request))
#12 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/route/dispatch/Controller.php(113): think\Pipeline->then(Object(Closure))
#13 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/route/Dispatch.php(89): think\route\dispatch\Controller->exec()
#14 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Route.php(772): think\route\Dispatch->run()
#15 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Pipeline.php(59): think\Route->think\{closure}(Object(app\Request))
#16 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->think\{closure}(Object(app\Request))
#17 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Route.php(773): think\Pipeline->then(Object(Closure))
#18 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Http.php(216): think\Route->dispatch(Object(app\Request), Object(Closure))
#19 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Http.php(206): think\Http->dispatchToRoute(Object(app\Request))
#20 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Pipeline.php(59): think\Http->think\{closure}(Object(app\Request))
#21 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/think-trace/src/TraceDebug.php(71): think\Pipeline->think\{closure}(Object(app\Request))
#22 [internal function]: think\trace\TraceDebug->handle(Object(app\Request), Object(Closure))
#23 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Middleware.php(142): call_user_func(Array, Object(app\Request), Object(Closure))
#24 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Pipeline.php(85): think\Middleware->think\{closure}(Object(app\Request), Object(Closure))
#25 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Pipeline.php(66): think\Pipeline->think\{closure}(Object(app\Request))
#26 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Http.php(207): think\Pipeline->then(Object(Closure))
#27 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/vendor/topthink/framework/src/think/Http.php(170): think\Http->runWithRequest(Object(app\Request))
#28 /Users/xuchi/Desktop/phpPro/pay.hdgame.vip/public/index.php(20): think\Http->run()
#29 {main}
写回答

1回答

代码酷

2021-05-23

在PHP 8.0和更高版本中,PHP使用2.9.0版的libxml,不推荐使用libxml_disable_entity_loader;

如果您想向后兼容,代码如下:


//判断PHP版本小于8则禁止引用外部xml实体
if (PHP_VERSION_ID < 80000) {    libxml_disable_entity_loader(true);}


0
0

全流程开发 TP6.0实战高并发电商服务系统

一课就能掌握TP6.0基础及运用,打造完整高并发的电商后端项目

1475 学习 · 1336 问题

查看课程