#23406 [Fbk->Opn]: \r\n not functioning the same from 4.3.1 and prior
| From: | gfraley5 at earthlink dot net | Date: | Wed, 30 Apr 2003 17:06:54 +0000 |
| Subject: | #23406 [Fbk->Opn]: \r\n not functioning the same from 4.3.1 and prior | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-38854@lists.php.net to get a copy of this message | ||
ID: 23406
User updated by: gfraley5 at earthlink dot net
Reported By: gfraley5 at earthlink dot net
-Status: Feedback
+Status: Open
Bug Type: Filesystem function related
Operating System: Win98SE,WinXP,Win2K
PHP Version: 4.3.2RC2
Assigned To: wez
New Comment:
From 4.2.3
Wrote: 76 bytes; filesize is now 80 ==== using readfile ===== msgid
1049987091 1050930128 ==== readfile read 80 bytes ==== ==== using fopen
'r' === msgid 1049987091 1050930128 ==== using fopen 'rb' === msgid
1049987091 1050930128 ==== done ===
From 4.3.2
Wrote: 76 bytes; filesize is now 77 ==== using readfile ===== msgid
1049987091 1050930128 ==== readfile read 77 bytes ==== ==== using fopen
'r' === msgid 1049987091 1050930128 ==== using fopen 'rb' === msgid
1049987091 1050930128 ==== done ===
Previous Comments:
------------------------------------------------------------------------
[2003-04-30 06:24:14] wez@php.net
I can't reproduce this here (tried 4.2.1 and 4.3.2 under XP).
NOTE: readfile() returns the number of bytes it wrote, NOT the contents
of the file.
Use file_get_contents() for that.
Please try this script on 4.3.2 and your 4.2.3 and report back (paste
the output from each into this report):
<?php
$myArray[] = 'msgid'."\r\n";
$myArray[] = '1049987091'."\r\n";
$myArray[] = '1050930128'."\r\n";
$l = 0;
$fp = fopen("problemFile.php",'w') or die("Unable to open file");
for ($i=0;$i<count($myArray);$i++) {
if ($i==0) {
$prefx = "<? Header(\"HTTP/1.0 403 Forbidden\");exit;?>\r\n";
} else {
$prefx = "";
}
$l += fwrite($fp, $prefx.$myArray[$i]);
}
fclose($fp);
echo "Wrote: $l bytes; filesize is now " . filesize("problemFile.php")
. "\n";
echo "==== using readfile =====\n";
$x = readfile("problemFile.php");
echo "==== readfile read $x bytes ====\n";
echo "==== using fopen 'r' ===\n";
$fp = fopen("problemFile.php", "r");
while (!feof($fp)) {
echo fgets($fp);
}
fclose($fp);
echo "==== using fopen 'rb' ===\n";
$fp = fopen("problemFile.php", "rb");
while (!feof($fp)) {
echo fgets($fp);
}
fclose($fp);
echo "==== done ===\n";
?>
------------------------------------------------------------------------
[2003-04-30 05:57:42] sniper@php.net
Wez: You broke it, fix it before 4.3.2 goes gold.
(some streams stuff :)
------------------------------------------------------------------------
[2003-04-29 16:34:34] gfraley5 at earthlink dot net
It works _perfectly_ under 4.2.3 WITHOUT using 'wb', just like 4.3.1!
That's the problem :(. I always upgrade before the finals are released
and it has always worked as just 'w'. Not only that, and hold on here,
but the windows version has NEVER required \r\n. It always works with
\n but that's a whole 'nother issue :)
------------------------------------------------------------------------
[2003-04-29 16:02:19] michael dot mauch at gmx dot de
<http://www.php.net/downloads.php> (scroll down
to where it says "PHP
4.2.3").
------------------------------------------------------------------------
[2003-04-29 14:24:35] gfraley5 at earthlink dot net
Where can I get the older version?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/23406
--
Edit this bug report at http://bugs.php.net/?id=23406&edit=1