The PHP array displays information such as phpinfo, ini, and extensions. phpinfotoarrayfunctionphpinfo_array ($ return = false) {ob_start (); phpinfo (-1); $ pi = preg_repla PHP array displays 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('$1', '', '', '', '
' . "\n", '<', ' ', ' ', ' ', '', ' ', 'PHP Configuration'."\n".'PHP Version$2'. "\n".'PHP Egg$1', 'PHP Credits Egg$1', 'Zend Engine$2' . "\n" . 'Zend Egg$1', ' ', '%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 (); // generally, the service provider shields print_r (PHP_VERSION );
?
3 .? Ini to array
$ini_path = php_ini_loaded_file();print_r($ini_path); $ini = parse_ini_file($ini_path);print_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[ $key ][] = $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
?
?
?
?
?