函式名稱:SolrResponse::getRawRequestHeaders()
適用版本:PECL solr >= 0.9.2
函式描述:該函式用於獲取Solr響應中原始的請求頭部資訊。
用法示例:
// 建立Solr客戶端
$options = array(
'hostname' => 'localhost',
'login' => 'solr',
'password' => 'secret',
'port' => 8983,
);
$client = new SolrClient($options);
// 建立查詢物件
$query = new SolrQuery();
$query->setQuery('php');
// 傳送查詢請求
$response = $client->query($query);
// 獲取原始請求頭部資訊
$headers = $response->getRawRequestHeaders();
// 列印請求頭部資訊
echo $headers;
上述示例中,我們首先建立了一個Solr客戶端物件,然後建立了一個查詢物件,並設定查詢關鍵詞為'php'。接下來,我們傳送查詢請求並將返回的響應儲存在$response變數中。最後,我們使用getRawRequestHeaders()
函式獲取原始的請求頭部資訊,並列印出來。
請注意,為了使用SolrResponse::getRawRequestHeaders()
函式,你需要安裝PECL solr擴充套件,並在程式碼中包含所需的名稱空間和類檔案。