Page 1 of 1

Problems with line lengths - php bug?

Posted: Wed Jun 26, 2002 8:45 pm
by plev
The following snippet of code is an example of the code that is causing me problems.

I am reading in html meta data (one meta data record per line) from a text file and inserting it into a html document.

I find that if the line of meta data gets long ~500 characters, php seems to insert a line break:

ie. the following line of input is cut off at the 496th character:

<meta name="DC.Description" content="The victim impact statement (VIS) is a significant initiative which embraces concerns about victims' rights in a manner consistent with existing legal principles. The author describes overseas and Australian legislative responses to this issue and presents the arguments for and against the VIS. She also presents research findings on key questions relating to the effects and outcomes of the VIS. She argues that the VIS should be considered for adoption by all Australian jurisdictions.">

resulting in the output (the first line is 505 characters long):

<meta name="DC.Description" content="The victim impact statement (VIS) is a significant initiative which embraces concerns about victims' rights in a manner consistent with existing legal principles. The author describes overseas and Australian legislative responses to this issue and presents the arguments for and against the VIS. She also presents research findings on key questions relating to the effects and outcomes of the VIS. She argues that the VIS should be considered for adoption by a</meta>
ll Australian jurisdictions."></meta>

which is clearly wrong. I have had similar problems in other scripts that I have written. Is this line length a limitation/bug of php? or of the host OS.

I am running php 4.0.4pl1 under Red Hat Linux 7.0 / Apache 1.3.14.

Thanks in advance,
Peter


-------

$MAXLINELENGTH=4096;

$fpm = fopen($file, "r");

while (!feof($fpm))
{
$line=fgets($fpm, $MAXLINELENGTH);

$line=trim($line);

if(strlen($line)>0)
{
$meta.=$line."</meta>\n";
}
}
fclose($fpm);

Posted: Wed Jun 26, 2002 11:14 pm
by kaizix
ok, i don't really know and this could be a guess, but might it have something to do with $MAXLINELENGTH ? just interesting that you would have it cut off at the 496th and $MAXLINELENGTH is 4096...maybe just a coincidence. so what if you make $MAXLINELENGTH smaller... just a hunch not really sure.

False alarm I'm afraid

Posted: Thu Jun 27, 2002 8:13 pm
by plev
The problem, which I must have overlooked at least a dozen times, ended up being in my script and is now resolved. Thanks to all those who replied.

Posted: Thu Jun 27, 2002 8:15 pm
by kaizix
so what was the problem? (so i don't think about it over and over)