Real PHP version:
$phpversion = preg_replace('/[a-z-]/', '', phpversion());
phpversion
(PHP 4, PHP 5)
phpversion — Gets the current PHP version
Описание
string phpversion
([ string $extension
] )
Returns a string containing the version of the currently running PHP parser or extension.
Список параметров
- extension
-
An optional extension name.
Возвращаемые значения
If the optional extension parameter is specified, phpversion() returns the version of that extension, or FALSE if there is no version information associated or the extension isn't enabled.
Примеры
Пример #1 phpversion() example
<?php
// prints e.g. 'Current PHP version: 4.1.1'
echo 'Current PHP version: ' . phpversion();
// prints e.g. '2.0' or nothing if the extension isn't enabled
echo phpversion('tidy');
?>
Примечания
Замечание: This information is also available in the predefined constant PHP_VERSION.
phpversion
djtopper at email dot cz
14-Apr-2008 12:57
14-Apr-2008 12:57
kalle at php dot net
10-Jan-2008 07:21
10-Jan-2008 07:21
On some machines phpversion() will not return a string in this format:
major.minor.version
But rather
major.minor.version-[os manufacturer]
I experinced this on a couple of Linux variants like Ubuntu.
So don't rely on the first format, I made this function to get the "real" version which might come in handy if you don't want the 'os manufacturer' part:
<?php
function phpversion_real()
{
$v = phpversion();
$version = Array();
foreach(explode('.', $v) as $bit)
{
if(is_numeric($bit))
{
$version[] = $bit;
}
}
return(implode('.', $version));
}
?>
