note 47907 deleted from function.dom-domdocument-validate by didou

From: Date: Sat, 30 Dec 2006 03:29:57 +0000
Subject: note 47907 deleted from function.dom-domdocument-validate by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121060@lists.php.net to get a copy of this message
Note Submitter: aidan at php dot net ---- This method throws E_NOTICE errors for any validation errors. If you'd rather store validation errors in an array for gracious handling, you can use the code below. <?php /** * Hold thrown errors statically */ function staticerror($errno, $errstr, $errfile, $errline, $errcontext, $ret = false) { static $errs = array(); if ($ret === true) { return $errs; } $tag = 'DOMDocument::validate(): '; $errs[] = str_replace($tag, '', $errstr); } // Load a document $dom = new DOMDocument; $dom->load('somefile'); // Set up error handling set_error_handler('staticerror'); $old = ini_set('html_errors', false); // Validate $doc->validate(); // Restore error handling ini_set('html_errors', $old); restore_error_handler(); // Get errors $errs = staticerror(null, null, null, null, null, true); print_r($errs); ?>

« previous php.notes (#121060) next »