PHP code example of zround / sphinxapi

1. Go to this page and download the library: Download zround/sphinxapi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zround / sphinxapi example snippets




use Zround\SphinxClient;

$cl = new SphinxClient();
$cl->SetServer('127.0.0.1', 9306);
$cl->SetConnectTimeout(3);

// Ping
if ($cl->Ping()) {
    echo "OK\n";
}

// 查询 / Query
$cl->SetLimits(0, 20);
$cl->SetArrayResult(true);
$result = $cl->Query('关键词', '索引名');

print_r($result);