php8.5
Home/ Manual/ driver / server/ MongoDB\Driver\Server::getHost

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"

See Also

Source: reference/mongodb/mongodb/driver/server/gethost.xml · from the official PHP manual (php/doc-en)