Serialize an ObjectId

- « MongoDB\BSON\ObjectId::jsonSerialize

- MongoDB\BSON\ObjectId::__toString »

- PHP Manual
- MongoDB\BSON\ObjectId
- Serialize an ObjectId

# MongoDB\BSON\ObjectId::serialize

(mongodb >=1.2.0)

MongoDB\BSON\ObjectId::serialize — Serialize an ObjectId

### Description

final public MongoDB\BSON\ObjectId::serialize(): string

### Parameters

This function has no parameters.

### Return Values

Returns the serialized representation of the MongoDB\BSON\ObjectId.

### Errors/Exceptions

- Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.

### See Also

- MongoDB\BSON\ObjectId::unserialize() - Unserialize an ObjectId
- serialize() - Generates a storable representation of a value
- Serializing Objects