Navigation
This version of the documentation is archived and no longer supported. To learn how to upgrade your version of PHP Library Manual, refer to the upgrade documentation.

MongoDB\Database::getDatabaseName()

Definition

MongoDB\Database::getDatabaseName

Returns the name of this database.

function getDatabaseName(): string

Return Values

The name of this database as a string.

Example

The following example prints the name of a database object:

<?php

$db = (new MongoDB\Client)->test;

echo $db->getDatabaseName();

The output would then resemble:

test