|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11961 \r\n or \n
Submitted: 2001-07-08 18:45 UTC Modified: 2002-06-02 14:03 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: wuxinan at 263 dot net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.0.6 OS: Win98 SE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: wuxinan at 263 dot net
New email:
PHP Version: OS:


 [2001-07-08 18:45 UTC] wuxinan at 263 dot net
I've submitted this bug some days before but I didn't get very kind reply. I decided to resubmit it.

	$fp = fopen("test.txt", "r");
	$str = "";
	while (!feof($fp)) $str .= fgets($fp, 64);
	echo count(split("\n", $str))."<br />".count(split("\r\n", $str));

And I've put 3 random lines in test.txt
OK, my PHP is running as Apache module, so when I type "localhost/test.php", I got the output "3<br />1".

Then, I run this script in CGI mode. This can be done simply by the command "c:\php_path\php.exe test.php", and I will get the output "3<br />3".

OK, so PHP is not portable, even in the same platform but different PHP running mode. CGI PHP and module PHP interpret "\r\n" differently.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-22 16:17 UTC]
 [2001-07-22 16:17 UTC]
 [2002-06-02 14:03 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from

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-2020 The PHP Group
All rights reserved.
Last updated: Thu Sep 24 00:01:24 2020 UTC