php如何获取文件内容?

例如:test.ini文件的内容如下
[group]
myname=**
myage=**
mysex=**

用php如何获得myage的值

第1个回答  推荐于2016-06-01
PHP 中的 file_get_contents() 函数可以实现

file_get_contents() 函数把整个文件读入一个字符串中。

和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串。

file_get_contents() 函数是用于将文件的内容读入到一个字符串中的首选方法。如果操作系统支持,还会使用内存映射技术来增强性能。

例如:

<?php
echo file_get_contents("test.txt");
?>
第2个回答  2011-06-03
我想可以用
file_get_contents();

正则匹配来获取
preg_match()
第3个回答  推荐于2018-02-26
$content = file_get_contents('test.ini');
$str = str_replace("\n", "&",str_replace("\r", "",$content));
$array = array();
parse_str($str, $array);
print_r($array);
echo $array['myage'];
$array['myage']就是myage的值。本回答被提问者和网友采纳
第4个回答  2011-06-03
parse_ini_file

如果你的ini标准的话~

参考资料:

第5个回答  2011-06-03
那你就读文件,取值呗...

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网