swish.examples.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 62 行
HTML
62 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Examples</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="swish.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.swish.html">Swish Functions</a></div> <div class="up"><a href="book.swish.html">Swish</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>Examples</h1> <div id="swish.examples-basic" class="section"> <h2 class="title">Basic usage</h2> <p class="para"> <div class="example"> <p><b>Example #1 Basic search query</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br /></span><span style="color: #007700">try {<br /><br /> </span><span style="color: #0000BB">$swish </span><span style="color: #007700">= new </span><span style="color: #0000BB">Swish</span><span style="color: #007700">(</span><span style="color: #DD0000">"index.swish-e"</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$results </span><span style="color: #007700">= </span><span style="color: #0000BB">$swish</span><span style="color: #007700">-></span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"test OR text"</span><span style="color: #007700">);<br /><br /> echo </span><span style="color: #DD0000">"Found "</span><span style="color: #007700">, </span><span style="color: #0000BB">$results</span><span style="color: #007700">-></span><span style="color: #0000BB">hits</span><span style="color: #007700">, </span><span style="color: #DD0000">" results\n"</span><span style="color: #007700">;<br /> while (</span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$results</span><span style="color: #007700">-></span><span style="color: #0000BB">nextResult</span><span style="color: #007700">()) {<br /> </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /> break; </span><span style="color: #FF8000">//break after the first result<br /> </span><span style="color: #007700">}<br /><br />} catch (</span><span style="color: #0000BB">SwishException $e</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"Error: "</span><span style="color: #007700">, </span><span style="color: #0000BB">$e</span><span style="color: #007700">-></span><span style="color: #0000BB">getMessage</span><span style="color: #007700">(), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para">The above example will output something similar to:</p> <div class="example-contents"><pre><div class="cdata"><pre>Found 9 resultsobject(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)}</pre></div> </pre></div> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="swish.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.swish.html">Swish Functions</a></div> <div class="up"><a href="book.swish.html">Swish</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?