当前位置:Gxlcms > PHP教程 > PHP数组展示phpinfo,ini,extensions等信息

PHP数组展示phpinfo,ini,extensions等信息

时间:2021-07-01 10:21:17 帮助过:34人阅读

PHP数组显示 phpinfo, ini, extensions等信息

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

?

来源:http://www.php.com/manual/en/function.phpinfo.php#87463

?

2. get_loaded_extensions? and PHP_VERSION

print_r(get_loaded_extensions());  

//print_r(apache_get_modules()); // 一般服务商都会屏蔽掉

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

?

来源:http://php.com/parse_ini_file

?

?

?

?

?

人气教程排行