php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2337 Referencing an array's element returns only 8k data
Submitted: 1999-09-20 12:39 UTC Modified: 2002-06-16 08:58 UTC
From: thifi at telnet dot hu Assigned:
Status: Not a bug Package: Other
PHP Version: 3.0.12 OS: Linux 2.2.10, Debian Potato
Private report: No CVE-ID: None
 [1999-09-20 12:39 UTC] thifi at telnet dot hu
I'm using Debian Potato's deb packages (3.0.12-5).

I used a file in which lines are longer than 8k.

When I read a file into an array with the "file" function and after I use "join" to join the elements into a string, the length of the joined string equals with the file's size.

But when I try to extract an item from the array, I only get back 8190 byte.

The problem only occurs when I use an array which is constructed by "file".

script to test with:
<?

$array = file("test.txt");
$file = join("",$array);
$size = filesize("test.txt");

echo("Reading the file into an array...\nFilesize: $size, Read in: ".strlen($file)."\n\n");

$file = file("test.txt");
$first = $file[0];

$file = fopen("test.txt","r");
$second = fgets($file,1000000);
fclose($file);

echo("Reading with \"file\" and \"fgets\"...\nFirst: ".strlen($first)." Second: ".strlen($second)."\n\n");

?>

test.txt's first line must be longer than 8190 bytes!

Thanks, Thifi

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-16 08:58 UTC] sander@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately, PHP 3 is no longer supported. Please download
the latest version of PHP 4 from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC