Construct a new document instance from a BSON string

- « MongoDB\BSON\Document::__construct

- MongoDB\BSON\Document::fromJSON »

- PHP Manual
- MongoDB\BSON\Document
- Construct a new document instance from a BSON string

# MongoDB\BSON\Document::fromBSON

(mongodb >=1.16.0)

MongoDB\BSON\Document::fromBSON — Construct a new document instance from a BSON string

### Description

final static public MongoDB\BSON\Document::fromBSON(string `$bson`): MongoDB\BSON\Document

### Parameters

`bson` (string)

  A string containing a document in BSON format.

### Return Values

Returns a new MongoDB\BSON\Document instance.

### Errors/Exceptions

- Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.
- Throws MongoDB\Driver\Exception\UnexpectedValueException if `bson` is an invalid BSON string or contains more than a single document.

### See Also

- MongoDB\BSON\Document::fromPHP() - Construct a new document instance from PHP data
- MongoDB\BSON\Document::fromJSON() - Construct a new document instance from a JSON string
- » BSON Types