php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45115 Problem with fgets and \ followed by n
Submitted: 2008-05-28 12:44 UTC Modified: 2008-07-13 15:10 UTC
From: gabriel dot magniez at steria dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.6 OS: Linux (Debian)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gabriel dot magniez at steria dot com
New email:
PHP Version: OS:

 

 [2008-05-28 12:44 UTC] gabriel dot magniez at steria dot com
Description:
------------
When I read a stream line by line with the function fgets, this function seems to interprete the two characters "\" followed by "n" as the "\n" (end of line) character.
My problem is that I attemp to read a shell script which contains these two characters but I would like that fgets don't transform these into the control character "\n".

Reproduce code:
---------------
$str = fgets($this->stream)

Expected result:
----------------
Only on line (ex: echo "abc\ndef")

Actual result:
--------------
Two lines:
echo "abc
def"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-13 15:10 UTC] jani@php.net
Don't use fgets() then, use fread().
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 03:01:26 2019 UTC