php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #185 fputs puts wrong count when Backslash in string
Submitted: 1998-03-18 00:55 UTC Modified: 1998-03-28 14:32 UTC
From: philip at qs dot co dot nz Assigned:
Status: Closed Package: Other
PHP Version: 3.0b6 OS: Linx-ELF i586
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: philip at qs dot co dot nz
New email:
PHP Version: OS:

 

 [1998-03-18 00:55 UTC] philip at qs dot co dot nz
If a backslash is in a string to fputs, then fputs adds an extra character
to the output stream for every backslash

for example:
  $ip="abc\def";
  fclose($fp);
  $fp = fopen("out","w+");
  $x=fputs($fp,"$ip");
  fclose($fp);

File out contains:

   61 62 63 5c 64 65 66 00
   a   b  c  \  d  e  f nul

The same result will be given for the string "abc\\def".


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-03-28 14:32 UTC] jim
This is the correct behavior. As noted in the ChangeLog for 3.0b4, "\Z" (where Z
is not one of the usual escape characters) leaves the backslash intact (and generates
an error message at the E_NOTICE level, which isn't usually printed). Putting in a
double backslash simply escapes the backslash and gives the same output.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 09 05:05:53 2022 UTC