<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mysql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.mysql-get-host-info.php',
    1 => 'mysql_get_host_info',
    2 => '取得 MySQL 主机信息',
  ),
  'up' => 
  array (
    0 => 'ref.mysql.php',
    1 => 'MySQL 函数',
  ),
  'prev' => 
  array (
    0 => 'function.mysql-get-client-info.php',
    1 => 'mysql_get_client_info',
  ),
  'next' => 
  array (
    0 => 'function.mysql-get-proto-info.php',
    1 => 'mysql_get_proto_info',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/mysql/functions/mysql-get-host-info.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.mysql-get-host-info" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysql_get_host_info</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.5, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_get_host_info</span> &mdash; <span class="dc-title">取得 MySQL 主机信息</span></p>

 </div>

 <div id="function.mysql-get-host-info-refsynopsisdiv">
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">本扩展自 PHP 5.5.0
起已废弃，并在自 PHP 7.0.0 开始被移除。应使用 <a href="book.mysqli.php" class="link">MySQLi</a>
或 <a href="ref.pdo-mysql.php" class="link">PDO_MySQL</a> 扩展来替换之。参见 <a href="mysqlinfo.api.choosing.php" class="link">MySQL：选择 API</a> 
指南来获取更多信息。用以替代本函数的有：</p>
   <ul class="simplelist">
    <li><span class="function"><a href="mysqli.get-host-info.php" class="function">mysqli_get_host_info()</a></span></li>
    <li>
     <span class="methodname"><a href="pdo.getattribute.php" class="methodname">PDO::getAttribute()</a></span>
     with <code class="parameter">attribute</code> as <strong><code><a href="pdo.constants.php#pdo.constants.attr-connection-status">PDO::ATTR_CONNECTION_STATUS</a></code></strong>
    </li>
   </ul>
  </div>
 </div>

 <div class="refsect1 description" id="refsect1-function.mysql-get-host-info-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mysql_get_host_info</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$link_identifier</code><span class="initializer"> = NULL</span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">
   描述 connection 中使用的连接类型，包括服务器主机名。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysql-get-host-info-parameters">
  <h3 class="title">参数</h3>
  <dl>
   <dt>
<code class="parameter">link_identifier</code></dt><dd><p class="para">MySQL
连接。如不指定连接标识，则使用由 <span class="function"><a href="function.mysql-connect.php" class="function">mysql_connect()</a></span>
最近打开的连接。如果没有找到该连接，会尝试不带参数调用
<span class="function"><a href="function.mysql-connect.php" class="function">mysql_connect()</a></span>
来创建。如没有找到连接或无法建立连接，则会生成
<strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> 级别的错误。</p></dd>

  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysql-get-host-info-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   Returns a string describing the type of MySQL connection in use for the
   connection 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mysql-get-host-info-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 <span class="function"><strong>mysql_get_host_info()</strong></span> 示例</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$link </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mysql_user'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mysql_password'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$link</span><span style="color: #007700">) {<br />    die(</span><span style="color: #DD0000">'Could not connect: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">mysql_error</span><span style="color: #007700">());<br />}<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"MySQL host info: %s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">mysql_get_host_info</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>以上示例的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">MySQL host info: Localhost via UNIX socket</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysql-get-host-info-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.mysql-get-client-info.php" class="function" rel="rdfs-seeAlso">mysql_get_client_info()</a> - 取得 MySQL 客户端信息</span></li>
   <li><span class="function"><a href="function.mysql-get-proto-info.php" class="function" rel="rdfs-seeAlso">mysql_get_proto_info()</a> - 取得 MySQL 协议信息</span></li>
   <li><span class="function"><a href="function.mysql-get-server-info.php" class="function" rel="rdfs-seeAlso">mysql_get_server_info()</a> - 取得 MySQL 服务器信息</span></li>
  </ul>
 </div>

</div><?php manual_footer($setup); ?>