首先,我们看一下以前的手册注释:
The MS SQL server. It can also include a port number, e.g. hostname:port (Linux), or hostname,port(Windows).
所以,看懂了吧?
没看懂?上代码
function db_connect()
{
if ($this->port != '')
{
if(strtoupper(substr(PHP_OS,0,3)) === 'WIN')
{
$this->hostname .= ','.$this->port;
}
else
{
$this->hostname .= ':'.$this->port;
}
}
return @mssql_connect($this->hostname, $this->username, $this->password);
}