MongoDB\Driver\Server::getHost
PHP function
Edit on GitHub ✎
(mongodb >=1.0.0)
Returns the hostname of this server
Description
MongoDB\Driver\Server::getHost(): string
Returns the hostname of this server.
Parameters Parameters
Return Values
Returns the hostname of this server.
Errors/Exceptions
Examples
MongoDB\Driver\Server::getHost() example
php
<?php
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017/");
$server = $manager->selectServer();
var_dump($server->getHost());
?>The above example will output:
output
string(9) "localhost"