PHP 5.4.33 Released

phpversion

(PHP 4, PHP 5)

phpversionRestituisce la versione del PHP

Descrizione

string phpversion ( void )

Restituisce una stringa contenente la versione dell'interprete PHP.

Nota:

Questa informazione รจ anche disponibile come costante predefinita PHP_VERSION.

Example #1 Esempio di uso di phpversion()

<?php
// Ad esempio visualizza 'Current PHP version: 4.1.1'
echo 'Current PHP version: ' phpversion();
?>

Vedere anche version_compare(), phpinfo(), phpcredits(), php_logo_guid() e zend_version().

add a note add a note

User Contributed Notes 3 notes

up
7
cHao
1 year ago
If you're trying to check whether the version of PHP you're running on is sufficient, don't screw around with `strcasecmp` etc.  PHP already has a `version_compare` function, and it's specifically made to compare PHP-style version strings.

<?php
if (version_compare(phpversion(), '5.3.10', '<')) {
   
// php version isn't high enough
}
?>
up
2
pavankumar at tutorvista dot com
3 years ago
To know, what are the {php} extensions loaded & version of extensions :

<?php
foreach (get_loaded_extensions() as $i => $ext)
{
   echo
$ext .' => '. phpversion($ext). '<br/>';
}
?>
up
-8
bitworks at web dot de
5 years ago
to realize if the actual version ist newer than '5.2.10'
simply use:

<?php
   
if (strnatcmp(phpversion(),'5.2.10') >= 0)
    {
       
# equal or newer
   
}
    else
    {
       
# not sufficiant
   
}
?>
To Top