PHP 4.0 Bug #6068 Updated: fread stops
| From: | Bug Database | Date: | Sun, 03 Sep 2000 22:06:40 +0000 |
| Subject: | PHP 4.0 Bug #6068 Updated: fread stops | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-31855@lists.php.net to get a copy of this message | ||
ID: 6068
Updated by: sniper
Reported By: richard@zend.com
Status: Closed
Bug Type: Misbehaving function
Assigned To:
Comments:
Feedback:
"Seems to work okay... But I don't have the exact same file to test on. :-("
Please reopen if this problem resurfaces later.
--Jani
Previous Comments:
[2000-09-02 22:31:19] sniper@php.net
Is this still happening with newer version? (Like php4.0.2 ?)
--Jani
---------------------------------------------------------------------------
[2000-08-10 06:17:54] richard@zend.com
<HTML><BODY>
<?php
set_time_limit(0);
clearstatcache();
$input = fopen('C:/phpcvs/phpcvs.tar.gz', 'r') or die('could not open
input');
$output = fopen('A:/phpcvs.tar.gz.1', 'w') or die('could not open
ouput');
$start = 0;
$chunk = 100;
$length = 1024*1024;
fseek($input, $start);
$current = $start;
echo "Filesize is ", filesize('C:/phpcvs/phpcvs.tar.gz'),
"<BR>n";
while ($current < $length && !feof($input)){
$data = fread($input, $chunk);
$wrote = fwrite($output, $data, $chunk);
$current += $wrote;
echo $current, "<BR>n";
flush();
}
$count = 330;
(fseek($input, 330)+1) or die ("Error fseeking 330<BR>n");
while (!feof($input) && $count < 350){
$char = fgetc($input);
echo ftell($input), " '$char' (", ord($char), ")<BR>n";
$count++;
}
fclose($input);
fclose($output);
echo "<BR>Done.";
?>
</BODY></HTML>
OUTPUT:
Filesize is 2233724
100
200
300
337
331 '' (0)
332 'S' (83)
333 ';' (59)
334 'N' (78)
335 ';' (59)
336 'õ' (245)
337 '|' (124)
338 '' (137)
842 'È' (200)
4427 '' (16)
4428 'x' (120)
4429 'F' (70)
4430 '^' (94)
4431 'e' (101)
4432 '' (154)
4433 'ë' (235)
4434 'ï' (239)
4435 '' (15)
4436 '7' (55)
4437 'b' (98)
Done.
Expected Output:
1.4 Megs copied 100 bytes at a time, and something sensible from ftell after byte 338...
filesize() knows how big the file is, but fread, feof, fgetc, etc are all convinced it's only
337 bytes long...
But char 337 and 338 are not even end of string. 331 is, but it's not even dying there, which
would almost make sense, except fread and fgetc are supposed to be binary safe...
The mod_php4.dll from that geocities guy is in there... Relevant? One wouldn't think so...
The php.exe seems to work just fine, so I guess it is though, unless it's in some other DLL
that gets involved with Apache and PHP somehow, but not with PHP.exe.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=6068