PHP 中的 file_get_contents() 函数可以实现file_get_contents() 函数把整个文件读入一个字符串中。和 file() 一样,不同的困轮是 file_get_contents() 把文件读入一个字符串。file_get_contents() 函数是用于将文森掘件的内容读入到一个字符串中的首选方法。如果操作系统支汪春信持,还会使用内存映射技术来增强性能。例如:<?phpecho file_get_contents("test.txt");?>
$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的值。