suche nach in der

phpversion> <phpcredits
Last updated: Sat, 07 Jan 2012

view this page in

phpinfo

(PHP 4, PHP 5)

phpinfoGibt Informationen zur PHP-Konfiguration aus

Beschreibung

bool phpinfo ([ int $what = INFO_ALL ] )

Zeigt eine große Anzahl von Informationen über den aktuellen Zustand von PHP an. Dies umfasst Informationen über die Optionen während des Kompilierens und die Extensions, die PHP-Version, Server-Informationen und -Umgebung (falls als Modul kompiliert), die PHP-Umgebung, Versionsinformationen zum Betriebssystem, Pfade, Master- und lokale Werte der Konfigurationsoptionen, HTTP-Header und die PHP-Lizenz.

Weil jedes System anders installiert ist, wird phpinfo() oft genutzt, um die Konfigurationseinstellungen und die verfügbaren vordefinierten Variablen auf einem System zu prüfen.

phpinfo() ist außerdem ein wertvolles Debugging-Tool, da es alle EGPCS-Daten (Environment, GET, POST, Cookie, Server) enthält.

Parameter-Liste

what

Die Ausgabe kann durch die bitweise summierte Angabe von einer oder mehrerer der folgenden Konstanten im optionalen what-Parameter angepasst werden. Die Konstanten oder Bitwerte können auch mit dem or-Operator kombiniert werden.

phpinfo()-Optionen
Name (Konstante) Wert Beschreibung
INFO_GENERAL 1 Die Konfigurationszeile, die Ort der php.ini, das Übersetzungsdatum, der Webserver, das System und mehr.
INFO_CREDITS 2 PHP-Credits. Siehe auch phpcredits().
INFO_CONFIGURATION 4 Aktueller lokaler und Master-Wert der PHP-Direktiven. Siehe auch ini_get().
INFO_MODULES 8 Die geladenene Module und ihre jeweiligen Einstellungen. Siehe auch get_loaded_extensions().
INFO_ENVIRONMENT 16 Informationen über die Umgebungsvariablen, die auch in $_ENV verfügbar ist.
INFO_VARIABLES 32 Zeigt alle vordefinierten Variablen aus EGPCS (Environment, GET, POST, Cookie, Server).
INFO_LICENSE 64 PHP-Lizenz-Informationen. Siehe auch » Lizenz-FAQ.
INFO_ALL -1 Zeigt alle genannten Informationen.

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Changelog

Version Beschreibung
5.2.2 Die Information über die "Loaded Configuration File" wurde hinzugefügt, während vorher nur die Information "Configuration File (php.ini) Path" existierte.

Beispiele

Beispiel #1 phpinfo()-Beispiel

<?php

// Zeigt alle Informationen (Standardwert ist INFO_ALL)
phpinfo();

// Zeigt nur die Modul-Informationen.
// phpinfo(8) führt zum gleichen Ergebnis.
phpinfo(INFO_MODULES);

?>

Anmerkungen

Hinweis:

Teile der angezeigten Informationen sind deaktiviert, wenn die expose_php-Konfigurationseinstellung auf off gesetzt ist. Dies umfasst die PHP- und Zend-Logos sowie die Credits.

Hinweis:

phpinfo() gibt reinen Text statt HTML aus, wenn es im CLI-Modus benutzt wird.

Siehe auch



add a note add a note User Contributed Notes
phpinfo
dev at cheechtech dot com
07-Jan-2007 10:35
same as above for configuration variables

function parsePHPConfig() {
    ob_start();
    phpinfo(INFO_CONFIGURATION);
    $s = ob_get_contents();
    ob_end_clean();
    $a = $mtc = array();
    if (preg_match_all('/<tr><td class="e">(.*?)<\/td><td class="v">(.*?)<\/td><td class="v">(.*?)<\/td><\/tr>/',$s,$mtc,PREG_SET_ORDER)) {
        foreach($mtc as $v){
            if($v[2] == '<i>no value</i>') continue;
            $a[$v[1]] = $v[2];
        }
    }
    return $a;
}
jb2386 at hotmail dot com
11-Oct-2006 06:29
This is a slight modification to the previous code by "code at adspeed dot com" that extracts the PHP modules as an array. I used it on PHP 4.1.2 and it failed as the <h2> tags also had an align="center". So this update changes the regex for those tags:

<?php

/* parse php modules from phpinfo */

function parsePHPModules() {
 
ob_start();
 
phpinfo(INFO_MODULES);
 
$s = ob_get_contents();
 
ob_end_clean();

 
$s = strip_tags($s,'<h2><th><td>');
 
$s = preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$s);
 
$s = preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$s);
 
$vTmp = preg_split('/(<h2[^>]*>[^<]+<\/h2>)/',$s,-1,PREG_SPLIT_DELIM_CAPTURE);
 
$vModules = array();
 for (
$i=1;$i<count($vTmp);$i++) {
  if (
preg_match('/<h2[^>]*>([^<]+)<\/h2>/',$vTmp[$i],$vMat)) {
  
$vName = trim($vMat[1]);
  
$vTmp2 = explode("\n",$vTmp[$i+1]);
   foreach (
$vTmp2 AS $vOne) {
  
$vPat = '<info>([^<]+)<\/info>';
  
$vPat3 = "/$vPat\s*$vPat\s*$vPat/";
  
$vPat2 = "/$vPat\s*$vPat/";
   if (
preg_match($vPat3,$vOne,$vMat)) { // 3cols
    
$vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
   } elseif (
preg_match($vPat2,$vOne,$vMat)) { // 2cols
    
$vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
   }
   }
  }
 }
 return
$vModules;
}
?>
php at SPAMMENOT dot tof2k dot com
10-Sep-2006 12:32
To obtain a phpinfo without headers (and css) :

<?
ob_start
();                                                                                                       
phpinfo();                                                                                                        
$info = ob_get_contents();                                                                                        
ob_end_clean();                                                                                                   
?>

$info = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);

You can then style your tables & headings :)
code at adspeed dot com
10-Dec-2005 12:31
This function parses the phpinfo output to get details about a PHP module.

/** parse php modules from phpinfo */
function parsePHPModules() {
 ob_start();
 phpinfo(INFO_MODULES);
 $s = ob_get_contents();
 ob_end_clean();
 
 $s = strip_tags($s,'<h2><th><td>');
 $s = preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$s);
 $s = preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$s);
 $vTmp = preg_split('/(<h2>[^<]+<\/h2>)/',$s,-1,PREG_SPLIT_DELIM_CAPTURE);
 $vModules = array();
 for ($i=1;$i<count($vTmp);$i++) {
  if (preg_match('/<h2>([^<]+)<\/h2>/',$vTmp[$i],$vMat)) {
   $vName = trim($vMat[1]);
   $vTmp2 = explode("\n",$vTmp[$i+1]);
   foreach ($vTmp2 AS $vOne) {
    $vPat = '<info>([^<]+)<\/info>';
    $vPat3 = "/$vPat\s*$vPat\s*$vPat/";
    $vPat2 = "/$vPat\s*$vPat/";
    if (preg_match($vPat3,$vOne,$vMat)) { // 3cols
     $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
    } elseif (preg_match($vPat2,$vOne,$vMat)) { // 2cols
     $vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
    }
   }
  }
 }
 return $vModules;
}

Sample Output:
[gd] => Array
(
  [GD Support] => enabled
  [GD Version] => bundled (2.0.28 compatible)
  [FreeType Support] => enabled
  [FreeType Linkage] => with freetype
  [FreeType Version] => 2.1.9
  [T1Lib Support] => enabled
  [GIF Read Support] => enabled
  [GIF Create Support] => enabled
  [JPG Support] => enabled
  [PNG Support] => enabled
  [WBMP Support] => enabled
  [XBM Support] => enabled
)

[date] => Array (
  [date/time support] => enabled
  [Timezone Database Version] => 2005.14
  [Timezone Database] => internal
  [Default timezone] => America/Los_Angeles
  [Directive] => Array (
     [0] => Local Value
     [1] => Master Value
  )
  [date.timezone] => Array (
     [0] => no value
     [1] => no value
  )
 )

/** get a module setting */
function getModuleSetting($pModuleName,$pSetting) {
 $vModules = parsePHPModules();
 return $vModules[$pModuleName][$pSetting];
}
Example: getModuleSetting('gd','GD Version'); returns "bundled (2.0.28 compatible)"
Helpful Harry
06-Oct-2005 05:38
check out this cool and fantastic colourful phpinfo()!

<?php

ob_start
();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();

preg_match_all('/#[0-9a-fA-F]{6}/', $phpinfo, $rawmatches);
for (
$i = 0; $i < count($rawmatches[0]); $i++)
  
$matches[] = $rawmatches[0][$i];
$matches = array_unique($matches);

$hexvalue = '0123456789abcdef';

$j = 0;
foreach (
$matches as $match)
{

  
$r = '#';
  
$searches[$j] = $match;
   for (
$i = 0; $i < 6; $i++)
     
$r .= substr($hexvalue, mt_rand(0, 15), 1);
  
$replacements[$j++] = $r;
   unset(
$r);
}

for (
$i = 0; $i < count($searches); $i++)
  
$phpinfo = str_replace($searches, $replacements, $phpinfo);
echo
$phpinfo;
?>

phpversion> <phpcredits
Last updated: Sat, 07 Jan 2012