PHP數組展示 phpinfo, ini, extensions等資訊

來源:互聯網
上載者:User
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.net/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.net/parse_ini_file

?

?

?

?

?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.