PHP array showing phpinfo, INI, extensions and other information

Source: Internet
Author: User
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

?

?

?

?

?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.