<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pgsql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.pg-version.php',
    1 => 'pg_version',
    2 => 'Returns an array with client, protocol and server version (when available)',
  ),
  'up' => 
  array (
    0 => 'ref.pgsql.php',
    1 => 'PostgreSQL Functions',
  ),
  'prev' => 
  array (
    0 => 'function.pg-update.php',
    1 => 'pg_update',
  ),
  'next' => 
  array (
    0 => 'class.pgsql-connection.php',
    1 => 'PgSql\\Connection',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pgsql/functions/pg-version.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pg-version" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_version</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_version</span> &mdash; <span class="dc-title">
   Returns an array with client, protocol and server version (when available)
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-version-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_version</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.pgsql-connection.php" class="type PgSql\Connection">PgSql\Connection</a></span></span> <code class="parameter">$connection</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_version()</strong></span> returns an array with the client, protocol
   and server version.
  </p>
  <p class="para">
   For more detailed server information, use <span class="function"><a href="function.pg-parameter-status.php" class="function">pg_parameter_status()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-version-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection</code></dt>
     <dd>
      <p class="para">An <span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span> instance.
When <code class="parameter">connection</code> is <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the default connection is used.
The default connection is the last connection made by <span class="function"><a href="function.pg-connect.php" class="function">pg_connect()</a></span>
or <span class="function"><a href="function.pg-pconnect.php" class="function">pg_pconnect()</a></span>.
<div class="warning"><strong class="warning">Warning</strong><p class="simpara">As of PHP 8.1.0, using the default connection is deprecated.</p></div></p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-version-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an array with <code class="literal">client</code>, <code class="literal">protocol</code> 
   and <code class="literal">server</code> keys and values (if available).
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-version-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  The <code class="parameter">connection</code> parameter expects an <span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span>
  instance now; previously, a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was expected.
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">connection</code> is now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-version-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>pg_version()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />  $dbconn </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"host=localhost port=5432 dbname=mary"</span><span style="color: #007700">)<br />     or die(</span><span style="color: #DD0000">"Could not connect"</span><span style="color: #007700">);<br />     <br />  </span><span style="color: #0000BB">$v </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_version</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />  <br />  echo </span><span style="color: #0000BB">$v</span><span style="color: #007700">[</span><span style="color: #DD0000">'client'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">7.4</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pg-version-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pg-parameter-status.php" class="function" rel="rdfs-seeAlso">pg_parameter_status()</a> - Looks up a current parameter setting of the server</span></li>
   </ul>
  </p>
 </div>

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