|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22497 php writes on wrong position in file after new lines
Submitted: 2003-03-01 16:06 UTC Modified: 2003-07-11 00:01 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: henrik dot gebauer at web dot de Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 4.3.2RC1 OS: Windows 2000
Private report: No CVE-ID: None
 [2003-03-01 16:06 UTC] henrik dot gebauer at web dot de
New line chars seem not to count any longer.
The following example writes 6 new lines in a file, then 20 chars.
'test' should be placed after the last '9' but it is placed after the last '3' (6 characters earlier as there are 6 new line chars)

I didn't have the problem with earlier versions of PHP.

$fp = fopen('file.txt', 'w');
fwrite($fp, 'test');


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-01 16:07 UTC] henrik dot gebauer at web dot de
Note: The new line chars can be everywhere in the first string.
 [2003-03-01 16:20 UTC] henrik dot gebauer at web dot de
sorry, Netscape filled the summary with the wrong contents.
 [2003-03-01 18:55 UTC]
Please show us the output produced by the script, and also the output that you expect the script to produce.
 [2003-03-02 05:49 UTC] henrik dot gebauer at web dot de
The script produces the following output with the current CVS version:

This is the output I expect. I get it with PHP 4.3.0 and earlier versions.
 [2003-03-03 09:34 UTC]
Cannot reproduce on Windows XP.
 [2003-03-04 10:27 UTC]
And I can't reproduce this in Windows 2000 using latest stable snapshot either. Please try again, but this time,
make sure you really update the PHP.

 [2003-03-04 16:06 UTC] henrik dot gebauer at web dot de
I can reproduce the bug with the last stable release for Windows of PHP 4.3.2-dev (From, Built On: Mar 04, 2003 17:30 GMT)
Replacing the php4ts.dll by the one of PHP 4.3.1 fixes the problem.
 [2003-03-04 19:29 UTC]
Are you 100% sure there isn't some clash with the versions now?? 

Also, does this happen with CLI/CGI ? 

What php.ini are you using? And what have you changed in it?
Are you loading any extensions in it?

If only you have this problem, and two developers can't reproduce it, it's most likely something wrong in your side, not in PHP..

 [2003-03-05 07:48 UTC] henrik dot gebauer at web dot de
I have my own php.ini. (changes: max_execution_time=5, error_reporting=E_ALL, include_path, extension_dir, extension=php_gd2.dll, session.save_path=C:\WINNT\TEMP and I have the Zend Optimizer installed)
But I tried it also with the php.ini-dist of the latest stable snapshot what didn't fix the bug.

Normally, I'm using PHP as an Apache2 module but I couldn't reproduce the bug with CGI/FastCGI.

It doesn't matter if I use a compiled snapshot or if I compile it by myself.
 [2003-03-05 12:34 UTC]
So the bug happens ONLY under Apache2 when you run PHP as apache module?

 [2003-03-05 14:04 UTC] henrik dot gebauer at web dot de
I tried the CGI version today and all chars were written into the file.
 [2003-03-09 18:40 UTC]
I'm not sure, but maybe this problem has something to do with _setmode() invocation in the CLI/CGI version.
 [2003-03-13 16:09 UTC] henrik dot gebauer at web dot de
I could locate the bug in 
by using old versions of those files (PHP 4.3.0)

I hope this helps.
 [2003-05-11 08:30 UTC]
Related to bug #22682

 [2003-07-11 00:01 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

See bug #22682 (add your comments there)

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun May 16 00:01:24 2021 UTC