예제 #1
0
function die_on_error($errno, $errstr, $file, $line)
{
    if ($file !== Null) {
        print $file;
        if ($line !== Null) {
            print ":{$line}";
        }
        print ": ";
    }
    print "{$errstr}\n";
    exit(1);
}
set_error_handler("die_on_error", -1);
include "xapian.php";
# Test the version number reporting functions give plausible results.
$v = Xapian::major_version() . '.' . Xapian::minor_version() . '.' . Xapian::revision();
$v2 = Xapian::version_string();
if ($v != $v2) {
    print "Unexpected version output ({$v} != {$v2})\n";
    exit(1);
}
$db = Xapian::inmemory_open();
$db2 = Xapian::inmemory_open();
# Check PHP5 handling of Xapian::DocNotFoundError
try {
    $doc2 = $db->get_document(2);
    print "Retrieved non-existent document\n";
    exit(1);
} catch (Exception $e) {
    if ($e->getMessage() !== "DocNotFoundError: Docid 2 not found") {
        print "DocNotFoundError Exception string not as expected, got: '{$e->getMessage()}'\n";