• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

php 搞代码 3年前 (2022-01-24) 14次浏览 已收录 0个评论
文章目录[隐藏]

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

1. phpinfo to array

function phpinfo_array($return=false){ 	ob_start(); 	phpinfo(-1);  	$pi = preg_replace( 	array('#^.*<body>(.*).*$#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 来2源gaodaima#com搞(代@码&网);

?

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

?

?

?

?

?


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP数组展示 phpinfo, ini, extensions等信息

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址