php如何获取文件内容?
答案:5 悬赏:40 手机版
解决时间 2021-02-14 20:51
- 提问者网友:听门外雪花风
- 2021-02-14 10:05
php如何获取文件内容?
最佳答案
- 五星知识达人网友:污到你湿
- 2021-02-14 11:03
PHP 中的 file_get_contents() 函数可以实现
file_get_contents() 函数把整个文件读入一个字符串中。
和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串。
file_get_contents() 函数是用于将文件的内容读入到一个字符串中的首选方法。如果操作系统支持,还会使用内存映射技术来增强性能。
例如:
echo file_get_contents("test.txt");
?>
file_get_contents() 函数把整个文件读入一个字符串中。
和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串。
file_get_contents() 函数是用于将文件的内容读入到一个字符串中的首选方法。如果操作系统支持,还会使用内存映射技术来增强性能。
例如:
echo file_get_contents("test.txt");
?>
全部回答
- 1楼网友:罪歌
- 2021-02-14 15:57
那你就读文件,取值呗...
- 2楼网友:傲气稳了全场
- 2021-02-14 14:45
parse_ini_file
如果你的ini标准的话~
如果你的ini标准的话~
参考资料:http://cn.php.net/manual/zh/function.parse-ini-file.php
- 3楼网友:刀戟声无边
- 2021-02-14 13:52
我想可以用
file_get_contents();
和
正则匹配来获取
preg_match()
file_get_contents();
和
正则匹配来获取
preg_match()
- 4楼网友:未来江山和你
- 2021-02-14 12:14
$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的值。
$str = str_replace("\n", "&",str_replace("\r", "",$content));
$array = array();
parse_str($str, $array);
print_r($array);
echo $array['myage'];
$array['myage']就是myage的值。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯