Docs Menu

Docs HomePHP Library Manual

MongoDB\Database::getDatabaseName()

On this page

  • Definition
  • Return Values
  • Example
MongoDB\Database::getDatabaseName()

Returns the name of this database.

function getDatabaseName(): string

The name of this database as a string.

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
←  MongoDB\Database::dropCollection()MongoDB\Database::getManager() →