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

search for in the

phpcredits> <php_sapi_name
Last updated: Fri, 11 Apr 2008

view this page in

php_uname

(PHP 4 >= 4.0.2, PHP 5)

php_uname — Devuelve información sobre el sistema operativo en el que está corriendo PHP

Descripción

string php_uname ([ string $modo ] )

php_uname() devuelve una descripción del sistema operativo en el que PHP está corriendo. Para el nombre de tan solo el sistema operativo, considere usar la constante PHP_OS, pero recuerde que esta constante contendrá el sistema operativo en el que PHP fue compilado.

En Unix, la salida recae a desplegar la información del sistema operativo en el que PHP fue compilado si no puede determinar el SO corriendo actualmente.

Lista de parámetros

modo

modo es un caracter sencillo que define la información a ser devuelta:

  • 'a': Este es el valor predeterminado. Contiene todos los modo en la secuencia "s n r v m".
  • 's': El nombre del sistema operativo. P.ej. FreeBSD.
  • 'n': Nombre del host. P.ej. localhost.example.com.
  • 'r': Nombre del lanzamiento. P.ej. 5.1.2-RELEASE.
  • 'v': Información de versión. Varía bastante entre sistemas operativos.
  • 'm': Tipo de máquina. P.ej. i386.

Valores retornados

Devuelve la descripción, como una cadena.

Ejemplos

Example #1 Algunos ejemplos de php_uname()

<?php
echo php_uname();
echo 
PHP_OS;

/* Algunas posibles salidas:
Linux localhost 2.4.21-0.13mdk #1 Fri Mar 14 15:08:06 EST 2003 i686
Linux

FreeBSD localhost 3.2-RELEASE #15: Mon Dec 17 08:46:02 GMT 2001
FreeBSD

Windows NT XN1 5.1 build 2600
WINNT
*/

if (strtoupper(substr(PHP_OS03)) === 'WIN') {
    echo 
'¡Este es un servidor usando Windows!';
} else {
    echo 
'¡Este es un servidor que no usa Windows!';
}

?>

También existen algunas constantes de PHP predefinidas relacionadas que podrían resultar útiles, por ejemplo:

Example #2 Algunos ejemplos de constantes relacionadas con el SO

<?php
// *nix
echo DIRECTORY_SEPARATOR// /
echo PHP_SHLIB_SUFFIX;    // so
echo PATH_SEPARATOR;      // :

// Win*
echo DIRECTORY_SEPARATOR// \
echo PHP_SHLIB_SUFFIX;    // dll
echo PATH_SEPARATOR;      // ;
?>



phpcredits> <php_sapi_name
Last updated: Fri, 11 Apr 2008
 
add a note add a note User Contributed Notes
php_uname
simon at NOSPAM dot zadra dot org
19-Jan-2006 06:26
Contrary to the last note, PHP_OS does display the OS PHP runs on currently, whereas php_uname() displays the Operating system version via uname.
This has nothing to do with the system PHP was built on.
michiel1978 /*at*/ hotmail /*dot*/ com
11-Dec-2005 11:38
Example 1 in this article is a little bit misleading. The comment on the last block of code says it will output the server's operating system, but in reality (and according to this same article), it will output the operating system on which PHP was built, because it uses the constant PHP_OS.
tac at smokescreen dot org
15-Jan-2005 12:25
In php 4.1.2, php_uname('n') returns a warning about an invalid parameter count.  Change it to @php_uname to hide this warning.

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