开发者

How to shut up simpleXML on malformed data? [duplicate]

开发者 https://www.devze.com 2022-12-10 17:26 出处:网络
This question already has answers here: simplexml error handling php (6 answers) Closed 7 years ago. I have a XML setting I am trying to load using simplexml. The XML setting can be edite
This question already has answers here: simplexml error handling php (6 answers) Closed 7 years ago.

I have a XML setting I am trying to load using simplexml. The XML setting can be edited by the user of a web application. I want to handle errors myself and dispatch a warning message to the user interface. However, simplexml keeps throwing warnings on malfor开发者_开发技巧med XML instead of quietly returning false.

How can I make simpleXML shut up and not throw a warning? Is there an option for that?


Use libxml_use_internal_errors() to suppress XML errors.

You can then use libxml_get_errors() to inspect any errors if you need to.


Put an @ in front of the function that is throwing the warning, this will suppress all warning messages.

0

精彩评论

暂无评论...
验证码 换一张
取 消