I want to GET a XML feed using simplexml_load_file()
and I want to handle the errors by myself. The problem is, libxml_use_internal_errors(true)
does not remove all the warnings. Here is my exact code:
<?php
libxml_use_internal_errors(true);
$url = "http://feeds.feedburner.com/GoogleOnlineSecurityBlog";
$res = simplexml_load_file($url);
When I purposefully write a typo in the URL, I get these warnings:
Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: Unknown host. in C:\xampp\htdocs\test.php on line 4
Warning: simplexml_load_file(http://feeds.feedburener.com/GoogleOnlineSecurityBlog): failed to open stream: php_network_getaddresses: getaddrinfo failed: Unknown host. in C:\xampp\htdocs\test.php on line 4
Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://feeds.feedburener.com/GoogleOnlineSecurityBlog" in C:\xampp\htdocs\test.php on line 4 error
Adding or removing libxml_use_internal_errors(true)
only adds/removes the last warning and not the first 2. What did I do wrong? I have PHP 7.2.2.
Thank you for your help.