Home >Backend Development >PHP Tutorial >Solve the problem of file_get_contents returning false when reading large files in PHP_PHP Tutorial
The file_get_contents file is used to read and write files, but I found an error message when using file_get_contents to read large files. Note: string can be as large as 2GB. This cannot exceed 2G. Is there a way to solve it? Below I Come and see it together.
If I read a www.bKjia.c0m file
The code is as follows
|
Copy code
|
||||||||
$u ='www.bKjia.c0m'; //This file is 100GB $a =file_get_contents( $u );
Run Tips Note: string can be as large as 2GB It cannot be larger than 2GB. Let’s go to the official website to see this function reference
I found one file_get_contents() reads the file into a string. Contents of length maxlen will be read starting at the position specified by the offset parameter. On failure, file_get_contents() returns FALSE. That’s it, let’s modify the program
|