ITPub博客

首页 > > > php连接mssql的疑问

php连接mssql的疑问

作者:doudourabbit 时间:2019-08-30 15:04:30 0 删除 编辑
<?php
$serverName = "serverName\sqlexpress"; //serverName\instanceName

// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"dbName");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}

为啥连接只需要提供服务器名字就可以,连接本机的和内网或者外网的服务器都是这样吗?

给个名字就能找到要连的原理是啥?

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4809/viewspace-3167644/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-25

  • 博文量
    193
  • 访问量
    1438