- PHP 手册
- 函数参考
- 搜索引擎扩展
- Swish
- 范例
Basic usage
Example #1 Basic search query
<?php
try {
$swish = new Swish("index.swish-e");
$results = $swish->query("test OR text");
echo "Found ", $results->hits, " results\n";
while ($result = $results->nextResult()) {
var_dump($result);
break; //break after the first result
}
} catch (SwishException $e) {
echo "Error: ", $e->getMessage(), "\n";
}
?>
以上例程的输出类似于:
Found 9 results object(SwishResult)#3 (8) { ["swishreccount"]=> int(1) ["swishrank"]=> int(1000) ["swishfilenum"]=> int(10) ["swishdbfile"]=> string(13) "index.swish-e" ["swishdocpath"]=> string(23) "README.SUBMITTING_PATCH" ["swishtitle"]=> NULL ["swishdocsize"]=> int(4557) ["swishlastmodified"]=> int(1072136752) }
User Contributed Notes
There are no user contributed notes for this page.官方地址:https://www.php.net/manual/en/swish.examples-basic.php