一、file_get_contents()和file()都是读文件
1、file_get_contents(path,include_path,context,start,max_length)
把整个文件读入一个字符串中

注:本函数可用于二进制对象
2、file(path,include_path,context)
把文件读入一个数组中,数组中每个单元都是文件中相应的一行,包括换行符。

注:如果碰到 PHP 在读取文件时不能识别 Macintosh 文件的行结束符,可以激活 auto_detect_line_endings 运行时配置选项。
二、explode和implode,互为相反函数
1、explode(separator,string,limit)使用一个字符串分割另一个字符串并返回由字符串组成的数组

2、implode(separator,array)将数组元素拼接成字符串

特别:implode() 函数接受两种参数顺序。但是由于历史原因,explode() 是不行的,您必须保证 separator 参数在 string 参数之前才行。
网友评论