Source of: /manual/ro/function.phpversion.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.info.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'ro',
),
'this' =>
array (
0 => 'function.phpversion.php',
1 => 'phpversion',
),
'up' =>
array (
0 => 'ref.info.php',
1 => 'Funcții pentru opțiuni/informații PHP',
),
'prev' =>
array (
0 => 'function.phpinfo.php',
1 => 'phpinfo',
),
'next' =>
array (
0 => 'function.putenv.php',
1 => 'putenv',
),
'alternatives' =>
array (
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.phpversion" class="refentry">
<div class="refnamediv">
<h1 class="refname">phpversion</h1>
<p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">phpversion</span> — <span class="dc-title">Gets the current PHP version</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.phpversion-description">
<h3 class="title">Descrierea</h3>
<div class="methodsynopsis dc-description">
<span class="type">string</span> <span class="methodname"><strong>phpversion</strong></span>
([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$extension</code></span>
] )</div>
<p class="para rdfs-comment">
Returns a string containing the version of the currently running PHP
parser or extension.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.phpversion-parameters">
<h3 class="title">Parametri</h3>
<p class="para">
<dl>
<dt>
<span class="term"><em><code class="parameter">extension</code></em></span>
<dd>
<p class="para">
An optional extension name.
</p>
</dd>
</dt>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.phpversion-returnvalues">
<h3 class="title">Valorile întoarse</h3>
<p class="para">
If the optional <em><code class="parameter">extension</code></em> parameter is
specified, <span class="function"><strong>phpversion()</strong></span> returns the version of that
extension, or <strong><code>FALSE</code></strong> if there is no version information associated or
the extension isn't enabled.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.phpversion-examples">
<h3 class="title">Exemple</h3>
<p class="para">
<div class="example" id="example-508">
<p><strong>Example #1 <span class="function"><strong>phpversion()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// prints e.g. 'Current PHP version: 4.1.1'<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Current PHP version: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">phpversion</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// prints e.g. '2.0' or nothing if the extension isn't enabled<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">phpversion</span><span style="color: #007700">(</span><span style="color: #DD0000">'tidy'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
</div>
</p>
<p class="para">
<div class="example" id="example-509">
<p><strong>Example #2 <strong><code>PHP_VERSION_ID</code></strong> example and usage</strong></p>
<div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// PHP_VERSION_ID is available as of PHP 5.2.7, if our <br />// version is lower than that, then emulate it<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">defined</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHP_VERSION_ID'</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">$version </span><span style="color: #007700">= </span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'.'</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_VERSION</span><span style="color: #007700">);<br /><br /> </span><span style="color: #0000BB">define</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHP_VERSION_ID'</span><span style="color: #007700">, (</span><span style="color: #0000BB">$version</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">] * </span><span style="color: #0000BB">10000 </span><span style="color: #007700">+ </span><span style="color: #0000BB">$version</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">] * </span><span style="color: #0000BB">100 </span><span style="color: #007700">+ </span><span style="color: #0000BB">$version</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">]));<br />}<br /><br /></span><span style="color: #FF8000">// PHP_VERSION_ID is defined as a number, where the higher the number <br />// is, the newer a PHP version is used. It's defined as used in the above <br />// expression:<br />//<br />// $version_id = $major_version * 10000 + $minor_version * 100 + $release_version;<br />//<br />// Now with PHP_VERSION_ID we can check for features this PHP version <br />// may have, this doesn't require to use version_compare() everytime <br />// you check if the current PHP version may not support a feature.<br />//<br />// For example, we may here define the PHP_VERSION_* constants thats <br />// not available in versions prior to 5.2.7<br /><br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">PHP_VERSION_ID </span><span style="color: #007700">< </span><span style="color: #0000BB">50207</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">define</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHP_MAJOR_VERSION'</span><span style="color: #007700">, </span><span style="color: #0000BB">$version</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]);<br /> </span><span style="color: #0000BB">define</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHP_MINOR_VERSION'</span><span style="color: #007700">, </span><span style="color: #0000BB">$version</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]);<br /> </span><span style="color: #0000BB">define</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHP_RELEASE_VERSION'</span><span style="color: #007700">, </span><span style="color: #0000BB">$version</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">]);<br /><br /> </span><span style="color: #FF8000">// and so on, ...<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
</div>
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.phpversion-notes">
<h3 class="title">Note</h3>
<blockquote class="note"><p><strong class="note">Notă</strong>:
<p class="para">
This information is also available in the predefined constant
<strong><code>PHP_VERSION</code></strong>. More versioning information
is available using the <strong><code>PHP_VERSION_*</code></strong>
constants.
</p>
</p></blockquote>
</div>
<div class="refsect1 seealso" id="refsect1-function.phpversion-seealso">
<h3 class="title">Vedeți de asemenea</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><a href="reserved.constants.php#reserved.constants.core" class="link">PHP_VERSION constants</a></li>
<li class="member"> <span class="function"><a href="function.version-compare.php" class="function" rel="rdfs-seeAlso">version_compare()</a> - Compares two "PHP-standardized" version number strings</span></li>
<li class="member"> <span class="function"><a href="function.phpinfo.php" class="function" rel="rdfs-seeAlso">phpinfo()</a> - Outputs information about PHP's configuration</span></li>
<li class="member"> <span class="function"><a href="function.phpcredits.php" class="function" rel="rdfs-seeAlso">phpcredits()</a> - Prints out the credits for PHP</span></li>
<li class="member"> <span class="function"><a href="function.php-logo-guid.php" class="function" rel="rdfs-seeAlso">php_logo_guid()</a> - Gets the logo guid</span></li>
<li class="member"> <span class="function"><a href="function.zend-version.php" class="function" rel="rdfs-seeAlso">zend_version()</a> - Gets the version of the current Zend engine</span></li>
</ul>
</p>
</div>
</div><?php manual_footer(); ?>