Docs Menu
Docs Home
/ / /
PHP Library Manual
/ /


On this page

  • Definition
  • Return Values
  • Example
  • See Also

Returns the namespace of the collection. A namespace is the canonical name of an index or collection in MongoDB.

function getNamespace(): string

The namespace of this collection as a string.

The following returns the namespace of the zips collection in the test database.

$collection = (new MongoDB\Client)->test->zips;
echo $collection->getNamespace();

The output would then resemble:

← MongoDB\Collection::getManager()