simplexml error handling php

前端 未结 7 1382
失恋的感觉
失恋的感觉 2020-11-27 19:50

I am using the following code:

function GetTwitterAvatar($username){
$xml = simplexml_load_file(\"http://twitter.com/users/\".$username.\".xml\");
$imgurl =          


        
7条回答
  •  北海茫月
    2020-11-27 20:50

    If you look at the manual, there is an options parameter:

    SimpleXMLElement simplexml_load_file ( string $filename [, string $class_name = "SimpleXMLElement" [, int $options = 0 [, string $ns = "" [, bool $is_prefix = false ]]]] )
    

    Options list is available: http://www.php.net/manual/en/libxml.constants.php

    This is the correct way to suppress warnings parsing warnings:

    $xml = simplexml_load_file('file.xml', 'SimpleXMLElement', LIBXML_NOWARNING);
    

提交回复
热议问题