PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

putenv> <phpinfo
Last updated: Fri, 11 Apr 2008

view this page in

phpversion

(PHP 4, PHP 5)

phpversion — Obtiene la versión de PHP actual

Descripción

string phpversion ([ string $extension ] )

Devuelve una cadena que contiene la versión del intérprete o extensión PHP corriendo actualmente.

Lista de parámetros

extension

Un nombre de extensión opcional.

Valores retornados

Si el parámetro opcional extension es especificado, phpversion() devuelve la versión de esa extensión, o FALSE si no hay información de versión asociada o la extensión no se encuentra habilitada.

Ejemplos

Example #1 Ejemplo de phpversion()

<?php
// imprime p.ej. 'Versión de PHP actual: 4.1.1'
echo 'Versión de PHP actual: ' phpversion();

// imprime p.ej. '2.0' o nada si la extensión no está habilitada
echo phpversion('tidy');
?>

Notes

Note: Esta información también se encuentra disponible en la constante predefinida PHP_VERSION.



add a note add a note User Contributed Notes
phpversion
djtopper at email dot cz
14-Apr-2008 09:57
Real PHP version:
$phpversion = preg_replace('/[a-z-]/', '', phpversion());
kalle at php dot net
10-Jan-2008 04: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));
    }
?>

putenv> <phpinfo
Last updated: Fri, 11 Apr 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites