Usage
The warnings are stored in an array called warnings which is public accessible.
To check is a warning exists you can use the method hasWarning().
This method returns true if there are warnings and false otherwise.
Exemple 56-2. Checking for warnings require_once 'Structures/BibTex.php';
$bibtex = new Structures_BibTex();
$ret = $bibtex->loadFile('foo.bib');
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
$bibtex->parse();
if ($bibtex->hasWarning()) {
print 'There are warnings!<br />';
} |
|
Every warning itself is hash table with the following keys:
warning - Type of the warning
entry - The line that caused the warning
wholeentry - The whole entry in which the warning occurred
To print every warning with type and line that caused the warning you could do something like this:
Exemple 56-3. Checking for warnings require_once 'Structures/BibTex.php';
$bibtex = new Structures_BibTex();
$ret = $bibtex->loadFile('foo.bib');
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
$bibtex->parse();
if ($bibtex->hasWarning()) {
foreach ($bibtex->warnings as $warning) {
echo 'Warning: '.$warning['warning'].'<br />';
echo 'Line: '.$warning['entry'].'<hr />';
}
} |
|
Finally if you want to clear all warnings you can use the method
clearWarnings().