Re: Re: RFC: Replacing errors with Exceptions

From: Date: Sat, 08 Aug 2009 09:47:23 +0000
Subject: Re: Re: RFC: Replacing errors with Exceptions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-45247@lists.php.net to get a copy of this message
Hannes Magnusson wrote on 30.07.2009 10:48: > Are you intentionally ignoring what I've said previously in the thread? > Please stop using SimpleXML as an example. You do not need @. > <?php > libxml_use_internal_errors(true); > $sxe = simplexml_load_string("<?xml > version='1.0'><broken><xml></broken>"); > if (!$sxe) { > echo "Failed loading XML\n"; > foreach(libxml_get_errors() as $error) { > echo "\t", $error->message; > } > } > > Outputs: > Failed loading XML > Blank needed here > parsing XML declaration: '?>' expected > Opening and ending tag mismatch: xml line 1 and broken > Premature end of data in tag broken line 1 > > No PHP warnings at all. > > > Again. The examples you are looking for are network issues with > fopen(), file_get_contents() and such things. I tested libxml_use_internal_errors() with XMLReader now, and it doesn't really work as intended. When calling $reader->read(), and reaching an invalid node, there is in fact the error stored in libxml_get_errors(), but PHP additionally still throws a "parse error" warning. When then trying to supress it there with @$reader->reader(), PHP doesn't throw the warning, but libxml also doesn't store the error internally. Passing libxml_noerror or libxml_nowarning to $reader->open() doesn't have any effect at all.

« previous php.internals (#45247) next »