函数名称:MongoDB\Driver\Server::__construct()
函数描述:该函数用于创建一个新的MongoDB服务器对象。
适用版本:该函数适用于MongoDB驱动程序版本1.0及更高版本。
语法:MongoDB\Driver\Server::__construct(string $host, int $port, array $options = [], array &$driverOptions = [])
参数:
返回值:该函数没有返回值。
示例:
$host = 'localhost';
$port = 27017;
// 创建服务器对象
$server = new MongoDB\Driver\Server($host, $port);
// 打印服务器对象
var_dump($server);
输出:
object(MongoDB\Driver\Server)#1 (4) {
["host"]=>
string(9) "localhost"
["port"]=>
int(27017)
["type"]=>
int(1)
["is_primary"]=>
bool(false)
}
注意事项: