(mongodb >=1.2.0)
MongoDB\BSON\Decimal128::__construct — 建構新的 Decimal128
注意: MongoDB\BSON\Decimal128 僅與 MongoDB 3.4+ 相容。嘗試將 BSON 類型與早期版本的 MongoDB 搭配使用將會導致錯誤。
value
(字串)十進位字串。
value
不是有效的十進位字串,則會擲出 MongoDB\Driver\Exception\InvalidArgumentException 例外。範例 #1 MongoDB\BSON\Decimal128::__construct() 範例
<?php
var_dump(new MongoDB\BSON\Decimal128(1234.5678));
var_dump(new MongoDB\BSON\Decimal128(NAN));
var_dump(new MongoDB\BSON\Decimal128(INF));
?>
上述範例將輸出類似以下的內容
object(MongoDB\BSON\Decimal128)#1 (1) { ["dec"]=> string(9) "1234.5678" } object(MongoDB\BSON\Decimal128)#1 (1) { ["dec"]=> string(3) "NaN" } object(MongoDB\BSON\Decimal128)#1 (1) { ["dec"]=> string(8) "Infinity" }