函式名稱:MongoDB\BSON\Binary::getData()
函式描述:該函式用於獲取MongoDB\BSON\Binary物件中的二進位制資料。
適用版本:MongoDB\BSON\Binary類在MongoDB擴充套件版本1.0.0及以上可用。
用法:
public function getData(): string
引數: 無引數。
返回值:
- 返回一個字串,表示MongoDB\BSON\Binary物件中的二進位制資料。
示例:
$binary = new MongoDB\BSON\Binary('Hello World', MongoDB\BSON\Binary::TYPE_GENERIC);
$data = $binary->getData();
echo $data; // 輸出:Hello World
在上面的示例中,我們建立了一個MongoDB\BSON\Binary物件,使用字串'Hello World'作為二進位制資料,並指定了資料型別為MongoDB\BSON\Binary::TYPE_GENERIC。然後,我們使用getData()函式獲取二進位制資料,並將其列印輸出。最終輸出結果為'Hello World'。