phpversion

(PHP 4, PHP 5, PHP 7, PHP 8)

phpversionRestituisce la versione del PHP

Descrizione

phpversion(): string

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

User Contributed Notes 3 notes

up
128
cHao
10 years 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
19
burninleo at gmx dot net
7 years ago
Note that the version string returned by phpversion() may include more information than expected: "5.5.9-1ubuntu4.17", for example.
up
18
pavankumar at tutorvista dot com
13 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/>';
}
?>
To Top