Problems with line lengths - php bug?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
plev
Forum Newbie
Posts: 2
Joined: Wed Jun 26, 2002 8:45 pm

Problems with line lengths - php bug?

Post 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);
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post 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.
plev
Forum Newbie
Posts: 2
Joined: Wed Jun 26, 2002 8:45 pm

False alarm I'm afraid

Post 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.
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post by kaizix »

so what was the problem? (so i don't think about it over and over)
Post Reply