php.net |  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
 [2008-08-19 15:50 UTC] php at richardneill dot org
Description:
------------
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].


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-07 22:33 UTC] cmb@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2015-07-07 22:33 UTC] cmb@php.net
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] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2015-07-10 17:43 UTC] cmb@php.net
> [...} 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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 15:01:30 2024 UTC