PHP Doku:: Gibt Informationen zur PHP-Konfiguration aus - function.phpinfo.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDas Verhalten von PHP beeinflussenPHP-Optionen und -InformationenPHP-Optionen-/-Informationen-Funktionenphpinfo

Ein Service von Reinhard Neidl - Webprogrammierung.

PHP-Optionen-/-Informationen-Funktionen

<<phpcredits

phpversion>>

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


15 BenutzerBeiträge:
- Beiträge aktualisieren...
arimbourg at ariworld dot eu
8.11.2010 16:28
This is necessary to obtain a W3C validation (XHTML1.0 Transitionnal)...
phpinfo's output is declared with that DTD :
- "System ID" has the wrong url to validate : "DTD/xhtml1-transitional.dtd" rather than "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
- Some module names contains space and the function's output use the name in anchors as ID and NAME. these attributes can't be validated like that (unique name only).

<?php

ob_start
();

ob_start ();                              // Capturing
phpinfo ();                               // phpinfo ()
$info = trim (ob_get_clean ());           // output

// Replace white space in ID and NAME attributes... if exists
$info = preg_replace ('/(id|name)(=["\'][^ "\']+) ([^ "\']*["\'])/i', '$1$2_$3', $info);

$imp = new DOMImplementation ();
$dtd = $imp->createDocumentType (
   
'html',
   
'-//W3C//DTD XHTML 1.0 Transitional//EN',
   
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
);
$doc = $imp->createDocument (
   
'http://www.w3.org/1999/xhtml',
   
'html',
   
$dtd
);
$doc->encoding = 'utf-8';

$info_doc = new DOMDocument ('1.0', 'utf-8');
/* Parse phpinfo's output
 * operator @ used to avoid messages about undefined entities
 * or use loadHTML instead
 */
@$info_doc->loadXML ($info);

$doc->documentElement->appendChild ( // Adding HEAD element to HTML
   
$doc->importNode (
       
$info_doc->getElementsByTagName ('head')->item (0),
       
true                         // With all the subtree
   
)
);
$doc->documentElement->appendChild ( // Adding BODY element to HTML
   
$doc->importNode (
       
$info_doc->getElementsByTagName ('body')->item (0),
       
true                         // With all the subtree
   
)
);

// Now you get a clean output and you are able to validate...
/*
echo ($doc->saveXML ());
//      OR
echo ($doc->saveHTML ());
 */

// By that way it's easy to add some style declaration :
$style = $doc->getElementsByTagName ('style')->item (0);
$style->appendChild (
   
$doc->createTextNode (
       
'/* SOME NEW CSS RULES TO ADD TO THE FUNCTION OUTPUT */'
   
)
);

// to add some more informations to display :
$body = $doc->getElementsByTagName ('body')->item (0);
$element = $doc->createElement ('p');
$element->appendChild (
   
$doc->createTextNode (
       
'SOME NEW CONTENT TO DISPLAY'
   
)
);
$body->appendChild ($element);

// to add a new header :
$head = $doc->getElementsByTagName ('head')->item (0);
$meta = $doc->createElement ('meta');
$meta->setAttribute ('name', 'author');
$meta->setAttribute ('content', 'arimbourg at ariworld dot eu');
$head->appendChild ($meta);

// As you wish, take the rest of the output and add it for debugging
$out = ob_get_clean ();

$pre = $doc->createElement ('div'); // or pre
$pre->setAttribute ('style', 'white-space: pre;'); // for a div element, useless with pre
$pre->appendChild ($doc->createTextNode ($out));
$body->appendChild ($pre);

$doc->formatOutput = true; // For a nice indentation
$doc->saveXML ();

?>

All that could be done with only RegExp but I prefer the use of DOM for manipulating documents
support at page2pagepro dot com
13.05.2010 19:36
I have been working extensively with portable Web Servers (i.e.: Uniform Server), and was trying to incorporate XSL, Tomcat and ASP. I decided first to 'modify' the way my php_info() appears, allowing a listing of currently loaded extensions. Hope someone finds this useful.

<?php

// Get PHP INFO
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$phpinfo = preg_replace ('/<\/div><\/body><\/html>/', '', $phpinfo);

//HR
$hr = '<div style="width:100%;background:#000; height:10px;margin-bottom:1em;"></div>'.PHP_EOL;

//GET EXT INFO
ob_start();
echo
'<table border="0" cellpadding="3" width="600">'.PHP_EOL;
echo
'<tr class="h"><td><a href="http://www.php.net/">';
echo
'<img border="0" src="http://static.php.net/www.php.net/images/php.gif" alt="PHP Logo" />';
echo
'</a><h1 class="p">PHP Extensions</h1>'.PHP_EOL;
echo
'</td></tr>'.PHP_EOL;
echo
'</table><br />'.PHP_EOL;
echo
'<h2>Overview</h2>'.PHP_EOL;
echo
'<table border="0" cellpadding="3" width="600">'.PHP_EOL;
echo
'<tr><td class="e">Extensions</td><td class="v">'.PHP_EOL;
$exts = array();
foreach (
get_loaded_extensions() as $ext) {
   
$exts[] = $ext;
}
echo
implode(', ', $exts).PHP_EOL;
echo
'</td></tr></table><br />'.PHP_EOL;
echo
'<h2>Details</h2>'.PHP_EOL;
echo
'<table border="0" cellpadding="3" width="600">'.PHP_EOL;
foreach (
$exts as $ext) {
    echo
'<tr><td class="e">'.$ext.'</td><td class="v">';
       
$funcs = array();
        foreach (
get_extension_funcs($ext) as $func) {
           
$funcs[] = $func;
        }
        echo
implode(', ', $funcs).PHP_EOL;
    echo
'</td></tr>'.PHP_EOL;
}
echo
'</table><br />'.PHP_EOL;
echo
'</div></body></html>'.PHP_EOL;
$extinfo = ob_get_contents();
ob_end_clean();

//OUTPUT
echo $phpinfo.$hr.$extinfo;

?>
webmaster at askapache dot com
6.12.2008 5:48
I wanted a simple *function* to convert the output of phpinfo into an array.  Here's what I came up with thanks to alot of the previous authors tips, and the source file: php-5.2.6/ext/standard/info.c

Call this function like phpinfo_array() prints the array, phpinfo_array(1) returns the array for your own processing.

== Sample Output ==
[PHP Configuration] => Array
 (
  [PHP Version] => 5.2.6
  [PHP Egg] => PHPE9568F34-D428-11d2-A769-00AA001ACF42
  [System] => Linux askapache 2.6.22.19-grsec3
  [Build Date] => Nov 11 2008 13:09:07
  [Configure Command] =>  ./configure --prefix=/home/grsec/bin/php
  [Server API] => FastCGI

  [IPv6 Support] => enabled
 [Zend Egg] => PHPE9568F35-D428-11d2-A769-00AA001ACF42
  [PHP Credits Egg] => PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
 )

[mbstring] => Array
 (
  [mbstring.http_input] => pass
  [mbstring.internal_encoding] => Array
    (
     [0] => ISO-8859-1
     [1] => no value
    )

  [mbstring.language] => neutral
   )

[mcrypt] => Array
 (
  [Version] => 3.5.7
  [Api No] => 20031217
 )

<?php
function phpinfo_array($return=false){
 
/* Andale!  Andale!  Yee-Hah! */
 
ob_start();
 
phpinfo(-1);
 
 
$pi = preg_replace(
 array(
'#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms',
 
'#<h1>Configuration</h1>#'"#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
 
"#[ \t]+#", '#&nbsp;#', '#  +#', '# class=".*?"#', '%&#039;%',
 
'#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
 
.'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
 
'#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
 
'#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
 
"# +#", '#<tr>#', '#</tr>#'),
 array(
'$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ',
 
'<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'.
 
"\n".'<tr><td>PHP Egg</td><td>$1</td></tr>',
 
'<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
 
'<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
 
'<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'),
 
ob_get_clean());

 
$sections = explode('<h2>', strip_tags($pi, '<h2><th><td>'));
 unset(
$sections[0]);

 
$pi = array();
 foreach(
$sections as $section){
  
$n = substr($section, 0, strpos($section, '</h2>'));
  
preg_match_all(
  
'#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
    
$section, $askapache, PREG_SET_ORDER);
   foreach(
$askapache as $m)
      
$pi[$n][$m[1]]=(!isset($m[3])||$m[2]==$m[3])?$m[2]:array_slice($m,2);
 }

 return (
$return === false) ? print_r($pi) : $pi;
}

?>
Phelon Dudras
28.11.2008 10:26
A simple method to style your own phpinfo() output.

<style type="text/css">
#phpinfo {}
#phpinfo pre {}
#phpinfo a:link {}
#phpinfo a:hover {}
#phpinfo table {}
#phpinfo .center {}
#phpinfo .center table {}
#phpinfo .center th {}
#phpinfo td, th {}
#phpinfo h1 {}
#phpinfo h2 {}
#phpinfo .p {}
#phpinfo .e {}
#phpinfo .h {}
#phpinfo .v {}
#phpinfo .vr {}
#phpinfo img {}
#phpinfo hr {}
</style>

<div id="phpinfo">
<?php

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

// the name attribute "module_Zend Optimizer" of an anker-tag is not xhtml valide, so replace it with "module_Zend_Optimizer"
echo ( str_replace ( "module_Zend Optimizer", "module_Zend_Optimizer", preg_replace ( '%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo ) ) ) ;

?>
</div>
bcofer at gmail dot com
25.11.2008 6:19
My hosting company doesn't let me edit my php.ini file, but I wanted most of the same values, so I adapted one of the above posts to let me convert the information from phpinfo into a page where so can just copy and paste the info into a new php.ini file.

<?php
ob_start
();
phpinfo(INFO_CONFIGURATION);
$phpinfo = array('phpinfo' => array());
if(
preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER))
    foreach(
$matches as $match)
        if(
strlen($match[1]))
           
$phpinfo[$match[1]] = array();
        elseif(isset(
$match[3]))
           
$phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
        else
           
$phpinfo[end(array_keys($phpinfo))][] = $match[2];
?>

<?php
   
foreach($phpinfo as $name => $section) {
         foreach(
$section as $key => $val) {
            if(
is_array($val))
                echo
"$key = $val[0]<br>";
            elseif(
is_string($key))
                echo
"$key = $val<br>";
            else
                echo
"$val<br>";
        }
        echo
"\n";
    }
?>
jon at sitewizard dot ca
6.07.2008 4:54
To extract all of the data from phpinfo into a nested array:
<?php
ob_start
();
phpinfo();
$phpinfo = array('phpinfo' => array());
if(
preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER))
    foreach(
$matches as $match)
        if(
strlen($match[1]))
           
$phpinfo[$match[1]] = array();
        elseif(isset(
$match[3]))
           
$phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
        else
           
$phpinfo[end(array_keys($phpinfo))][] = $match[2];
?>

Some examples of using individual values from the array:

<?php
   
echo "System: {$phpinfo['phpinfo']['System']}<br />\n";
    echo
"Safe Mode: {$phpinfo['PHP Core']['safe_mode'][0]}<br />\n";
    echo
"License: {$phpinfo['PHP License'][0]}<br />\n";
?>

To display everything:

<?php
   
foreach($phpinfo as $name => $section) {
        echo
"<h3>$name</h3>\n<table>\n";
        foreach(
$section as $key => $val) {
            if(
is_array($val))
                echo
"<tr><td>$key</td><td>$val[0]</td><td>$val[1]</td></tr>\n";
            elseif(
is_string($key))
                echo
"<tr><td>$key</td><td>$val</td></tr>\n";
            else
                echo
"<tr><td>$val</td></tr>\n";
        }
        echo
"</table>\n";
    }
?>

Note: In order to properly retrieve all of the data, the regular expression matches table headers as well as table data, resulting in 'Local Value' and 'Global Value' showing up as 'Directive' entries.
yurkins
23.06.2008 16:24
big thanx 2 Mardy dot Hutchinson at gmail dot com
very good!

some fixes to correct result displaying:
1. we need to trim $matches [1], 'cause there can be empty lines;
2. not bad to remove <body> tag 'cause styles for it not apply correctly...
3. ...and change styles a little (remove "body" selector)

we need to change two lines:

<?php
preg_match
('%<style type="text/css">(.*?)</style>.*?(<body>.*</body>)%s', ob_get_clean(), $matches);
?>
to
<?php
preg_match
('%<style type="text/css">(.*?)</style>.*?<body>(.*?)</body>%s', ob_get_clean(), $matches);
?>

and

<?php
preg_split
( '/\n/', $matches[1] )
?>
to
<?php
preg_split
( '/\n/', trim(preg_replace( "/\nbody/", "\n", $matches[1])) )
?>

That's all! Now we have a really flexible addition to phpinfo();
Mardy dot Hutchinson at gmail dot com
10.09.2007 0:27
Embedding phpinfo within your page, that already has style information:

The phpinfo output is wrapped within a <div class='phpinfodisplay'>, and we privatize all the style selectors that phpinfo() creates.

Yes, we cheat on preparing the selector list.

<?php
ob_start
();
phpinfo();

preg_match ('%<style type="text/css">(.*?)</style>.*?(<body>.*</body>)%s', ob_get_clean(), $matches);

# $matches [1]; # Style information
# $matches [2]; # Body information

echo "<div class='phpinfodisplay'><style type='text/css'>\n",
   
join( "\n",
       
array_map(
           
create_function(
               
'$i',
               
'return ".phpinfodisplay " . preg_replace( "/,/", ",.phpinfodisplay ", $i );'
               
),
           
preg_split( '/\n/', $matches[1] )
            )
        ),
   
"</style>\n",
   
$matches[2],
   
"\n</div>\n";
?>

Perhaps one day the phpinfo() function will be modified to output such a safe string on its own.
Andrew dot Boag at catalyst dot net dot nz
9.09.2007 9:47
One note on the above functions for cleaning up the phpinfo() HTML and throwing it into an array data structure. In order to catch all of the info tidbits the preg_match_all has to be tweaked to deal with 2 and 3 column tables.

I have changed the preg_match_all() here so that the last <td></td> is optional

<?php
function parsePHPConfig() {
   
ob_start();
   
phpinfo(-1);
   
$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;
}
?>
jo at durchholz dot org
14.08.2007 11:43
Here's a variant of "print it without headers, but include the style information":

<?php
ob_start
();
phpinfo();
$info = ob_get_clean ();

$matches = array ();
$i = preg_match ('%(<style type="text/css">.*</style>).*<body>(.*)</body>%s', $info, $matches);

print
$matches [1]; # Style information
print $matches [2]; # Body
dev at cheechtech dot com
7.01.2007 10:35
same as above for configuration variables

<?php
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.10.2006 6: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.09.2006 12:32
To obtain a phpinfo without headers (and css) :

<?php
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.12.2005 0:31
This function parses the phpinfo output to get details about a PHP module.

<?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;
}
?>

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
  )
 )


<?php
/** 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
6.10.2005 17: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;
?>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)