PHP array display phpinfo, INI, extensions and other information
1. Phpinfo to Array
function Phpinfo_array ($return =false) {Ob_start (); Phpinfo (-1); $pi = preg_replace (Array (' #^.*(.*). *$ #ms ', ' #PHP License
. *$ #ms ', ' #Configuration
# ', "#\r?\n#", "#
# ", ' # +<# '," #[\t]+# ", ' # # ', ' # +# ', ' # class= '. *?" #', '%'%', '#(?:.*?)" Src= "(?:. *?) =(.*?)" alt= "PHP Logo"/> '. 'PHP Version (. *?)
(?:\ N+?)#', '#PHP Credits
#', '#(?:.*?)" Src= "(?:. *?) =(.*?)" (?:.*?) Zend Engine (. *?), (?:. *?)#', "# +#", '##', '## '), Array (' $ ', ' ', ', ', '
' . "\ n", ' < ', ', ', ', ', ', ', 'PHP Configuration
'." \ n "."PHP Version$'. "\ n". 'PHP Egg$', 'PHP Credits Egg$', 'Zend Engine$' . "\ n". 'Zend Egg$', ', '%s% ', '%e% '), Ob_get_clean ()); $sections = Explode ('', Strip_tags ($pi, '
')); unset ($sections [0]); $pi = Array (); foreach ($sections as $section) {$n = substr ($section, 0, Strpos ($section, '
')); Preg_match_all (' #%s% (?:(.*?))? (?:(.*?))? (?:(.*?))?%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;} Phpinfo_array ();
?
Source: http://www.php.net/manual/en/function.phpinfo.php#87463
?
2. Get_loaded_extensions? and php_version
Print_r (Get_loaded_extensions ()); Print_r (Apache_get_modules ()); General Service providers will shield off Print_r (php_version);
?
3.? INI to array
$ini _path = Php_ini_loaded_file ();p rint_r ($ini _path); $ini = Parse_ini_file ($ini _path);p rint_r ($ini);
?
Or
function Parse_ini ($filepath) {$ini = file ($filepath); if (count ($ini) = = 0) {return array ();} $sections = Array (); $values = Array (); $globals = Array (); $i = 0; foreach ($ini as $line) {$line = Trim ($line); Comments if ($line = = "| | $line {0} = = '; ') {continue;} Sections if ($line {0} = = ' [') {$sections [] = substr ($line, 1,-1); $i + +; Continue }//Key-value pair list ($key, $value) = explode (' = ', $line, 2); $key = Trim ($key); $value = Trim ($value); if ($i = = 0) {//Array values if (substr ($line,-1, 2) = = ' [] ') {$globals [$k EY] [] = $value; } else {$globals [$key] = $value; }} else {//Array values if (substr ($line,-1, 2) = = ' [] ') {$values [$i -1] [$key] = $value; } ELSE {$values [$i-1] [$key] = $value; }}} for ($j =0; $j < $i; $j + +) {$result [$sections [$j]] = $values [$j]; } return $result + $globals;} $stores = Parse_ini ($ini _path);//print_r ($stores);
?
Source: Http://php.net/parse_ini_file
?
?
?
?
?