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

MongoDB\Collection::getCollectionName()

On this page

  • Definition
  • Return Values
  • Example
  • See Also
MongoDB\Collection::getCollectionName()

Returns the name of this collection.

function getCollectionName(): string

The name of this collection as a string.

The following returns the collection name for the zips collection in the test database.

<?php
$collection = (new MongoDB\Client)->test->zips;
echo $collection->getCollectionName();

The output would then resemble:

zips
  • MongoDB\Collection::getDatabaseName()

  • MongoDB\Collection::getNamespace()

Back

findOneAndUpdate()