PHP is not read complete file. Memory and time?

0 like 0 dislike
42 views
There is a script which perfectly worked on localhost for 2 years on different versions of php loads and parses data from a csv file. Actually, the files are not that large — the maximum is 22 MB.

After the next reinstallation of system (win7 64bit ultimate on the same home premium) and reconfigure the web server (installing new minor versions of Apache, php and mysql) import suddenly went wrong — team file, fgets, file_get_contents and other suddenly started to give only a piece of the file. All is dancing around the numbers in around 65 KB, more accurately does not read, sometimes less.


In the config spelled out memory_limit = 512M, max_execution_time = 1800


Full config PHP: pastebin.com/rTiRr53t

The full configuration of Apache: pastebin.com/uSmpP684


Files are read like this:
$file_loc = 'pathtofile/file.dat';
$lines = file($file_loc);

foreach ($lines as $line_num => $line)
{
echo $line;
}



After another moment the string breaks. Google refers to memory_limit and boot parts using various tricks, but I worked and loading at one time, since the files are not huge. Rollback to a previous version of PHP did not help.


What am I missing?
by | 42 views

7 Answers

0 like 0 dislike
The problem is, I think, not in the configuration.
\r
View the correct size filesize($file_loc).
\r
If Yes, can try the old way?
$fh = fopen($file_loc, "rb");
$data = fread($fh, filesize($file_loc));
fclose($fh);
\r
Or even to read in parts?
while (!feof($fh))
$mytext = fgets($fh, 1024);
by
0 like 0 dislike
1. The function of converting the encoding used? (Directly or indirectly).
2. What version of PHP before that was?
\r
It is highly desirable to obtain the code itself or a fragment thereof.
by
0 like 0 dislike
And try to use file instead of file_get_contents
by
0 like 0 dislike
And you the php.ini right? PHP have several of them for different options of start up (apache, cli, FastCGI).
by
0 like 0 dislike
You are using "line" file() to read binary files? Very interesting. Really, try file_get_contents().
by
0 like 0 dislike
Once have long struggled with the problem (everything right and nothing works), and then the problem was the suhosin patch.
\r
Could it be in this case?
by
0 like 0 dislike
And try to compare the results filesize($file_loc) and strlen(file_get_contents($file_loc)).
The size of read data always the same?
Maybe it's in the data?
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
110,608 questions
257,186 answers
0 comments
28,881 users