file_get_contents文件是用来读写文件的,但我发现用file_get_contents 读取大文件出错提示Note: string can be as large as 2GB了,这个就是不能超过2G了,有没有办法解决呢,下面我来一起来看。
如果我读取一个 www.111cn.net文件
代码如下 | 复制代码 | ||||
$u ='www.111cn.net'; //此文件为100GB $a =file_get_contents( $u ); 运行提示 Note: string can be as large as 2GB 不能大于2GB了,我们去官方看此函数参考 string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] ) 发现有个 file_get_contents() 把文件读入一个字符串。将在参数 offset 所指定的位置开始读取长度为 maxlen 的内容。如果失败, file_get_contents() 将返回 FALSE。 原来如此,这样我们对程序进行修改即可
|