|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45864 wish: fwrite to support direct output of bytes (not cast to string)
Submitted: 2008-08-19 15:50 UTC Modified: 2015-07-10 17:43 UTC
From: php at richardneill dot org Assigned: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
49 - 7 = ?
Subscribe to this entry?

 [2008-08-19 15:50 UTC] php at richardneill dot org
fwrite() outputs to file as a string. While this is usually a 
sensible default, it can be rather annoying when I actually want to 
output raw data.  I know about using chr(), but that's ugly at least.

My request: add an option to fwrite that lets you output a char, 
rather than a string.

[The chr() workaround is also not very visibly documented].


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-07 22:33 UTC]
-Package: Feature/Change Request +Package: *General Issues
 [2015-07-07 22:33 UTC]
That seems too low-level to me. As PHP strings may contain
arbitrary bytes, you can easily build up the desired output
string(s) with pack('c*', ...) and write this/these to the file.
 [2015-07-09 22:26 UTC] php at richardneill dot org
-Status: Open +Status: Closed
 [2015-07-09 22:26 UTC] php at richardneill dot org
I the person who originally wrote this request, I think my 7-year-ago self didn't know enough C to really realise what I was talking about. The pack() answer is clearly a better solution. Thanks for your time, and please feel free to close this as wontfix.
 [2015-07-10 17:43 UTC]
-Assigned To: +Assigned To: cmb
 [2015-07-10 17:43 UTC]
> [...} please feel free to close this as wontfix.

IMHO "closed" is fine: you've submitted a feature request, and
withdrew it after consideration. :)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Apr 02 03:03:39 2023 UTC