php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27671 Problem in outputbuffer
Submitted: 2004-03-24 08:04 UTC Modified: 2004-03-25 03:37 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: venkateshp_2004 at yahoo dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5CVS-2004-03-24 (dev) OS: windows 2000
Private report: No CVE-ID: None
 [2004-03-24 08:04 UTC] venkateshp_2004 at yahoo dot com
Description:
------------
Hi..! 
 
When i write the contents of the buffer which contains the data from ob_get_contents() in a file, Instead of '\n' I am getting the unknown charecter when i opend with the the file by using notepad.It is creating big problem when make CRC32check of the two files.I would be thankfull to you if you could solve it.

yours,
venki

Reproduce code:
---------------
<?php
ob_start();
echo "\nThis is the test-line1\n";
echo "\n this is the test-line2\n";
$data=ob_get_contents();
$filename="test.txt";
$handle=fopen($filename,"a+");
fwrite($handle,$data);
?>

Expected result:
----------------
In the file "test.txt" I am expecting the following
contents in the file when i opend with the notepad (not with the php editor).

This is the test line1

This is the test line2

Actual result:
--------------
But i am getting some unknown symbol like this...


0This is the test line1 00This is the test line20



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-25 03:18 UTC] nelson_menezes at hotmail dot com
This is not a bug; it's normal behaviour. Windows notepad works with the standard windows text-file format, which requires two characters for new lines (carriage return + line feed). Most other OS's only require line feed. If you use Wordpad (which supports unix-style endlines) instead of Notepad you'll see everything is as it should.

Replace with these lines in your code:

echo "\r\nThis is the test-line1\r\n";
echo "\r\n this is the test-line2\r\n";

Notepad should then show what you want.
 [2004-03-25 03:37 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

See last message.

You may also want to use open mode modifier \'t\' on windows systems which automatically converts \\n to \\r\\n.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat May 28 04:06:34 2022 UTC