查詢

MongoDB\BSON\Decimal128::__construct()函式—用法及示例

「 建立一個新的 MongoDB\BSON\Decimal128 物件 」


函式名稱:MongoDB\BSON\Decimal128::__construct()

適用版本:PHP 5.6.0+

用法:該函式用於建立一個新的 MongoDB\BSON\Decimal128 物件。

語法:public MongoDB\BSON\Decimal128::__construct(string $value)

引數:

  • $value: 要表示為 Decimal128 的字串值。

返回值:無返回值。

示例:

// 建立一個新的 Decimal128 物件
$decimal = new MongoDB\BSON\Decimal128('123.456');

// 列印 Decimal128 物件的值
echo $decimal->getValue(); // 輸出:123.456

注意事項:

  • 傳遞給建構函式的字串值必須是有效的十進位制數。
  • Decimal128 物件在 MongoDB\BSON\Decimal128 類中定義,可以用於在 MongoDB 中儲存和操作高精度的十進位制數值。
  • Decimal128 物件的值可以透過呼叫 getValue() 方法獲取。
  • Decimal128 物件在 MongoDB 驅動程式中廣泛使用,特別是在處理金融和貨幣資料時非常有用。
補充糾錯
熱門PHP函式
分享連結