Please wait while we load your page...
 

Announcements

PHP Manual :: MongoDB\BSON\ObjectID::__construct



MongoDB\BSON\ObjectID || MongoDB\BSON\ObjectID::__toString || PHP Manual

(mongodb >=1.0.0)

MongoDB\BSON\ObjectID::__constructConstruct a new ObjectID

Description

final public MongoDB\BSON\ObjectID::__construct ([ string $id ] )

Parameters

id (string)

A 24-character hexadecimal string. If not provided, the driver will generate an ObjectID.

Errors/Exceptions

Examples

Example #1 MongoDB\BSON\ObjectID::__construct() example

<?php

var_dump
(new MongoDB\BSON\ObjectId());

var_dump(new MongoDB\BSON\ObjectId('000000000000000000000001'));

?>

The above example will output something similar to:

object(MongoDB\BSON\ObjectID)#1 (1) {
  ["oid"]=>
  string(24) "56732d3dda14d81214634921"
}
object(MongoDB\BSON\ObjectID)#1 (1) {
  ["oid"]=>
  string(24) "000000000000000000000001"
}



MongoDB\BSON\ObjectID || MongoDB\BSON\ObjectID::__toString || PHP Manual
Live Chat Not Available