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">&lt;?php<br /><br /></span><span style="color: #007700">try&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$swish&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</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 />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$results&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$swish</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"test&nbsp;OR&nbsp;text"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Found&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$results</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hits</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"&nbsp;results\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$results</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">nextResult</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;&nbsp;</span><span style="color: #FF8000">//break&nbsp;after&nbsp;the&nbsp;first&nbsp;result<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br /><br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">SwishException&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Error:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">(),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</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) {  [&quot;swishreccount&quot;]=&gt;  int(1)  [&quot;swishrank&quot;]=&gt;  int(1000)  [&quot;swishfilenum&quot;]=&gt;  int(10)  [&quot;swishdbfile&quot;]=&gt;  string(13) &quot;index.swish-e&quot;  [&quot;swishdocpath&quot;]=&gt;  string(23) &quot;README.SUBMITTING_PATCH&quot;  [&quot;swishtitle&quot;]=&gt;  NULL  [&quot;swishdocsize&quot;]=&gt;  int(4557)  [&quot;swishlastmodified&quot;]=&gt;  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 + -
显示快捷键?