Re: How to write binary data to a file?
| From: | Christoph Becker | Date: | Tue, 26 Jul 2016 23:58:21 +0000 |
| Subject: | Re: How to write binary data to a file? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325667@lists.php.net to get a copy of this message | ||
On 27.07.2016 at 01:47, David Spector wrote:
> Clearly, the problem was with fwrite converting its value to a
> character. It shouldn't do this, IMO, since fwrite is documented as
> working both for string and binary arguments (depending on the 'b' mode
> of fopen).
The "b" mode only prevents line endings (CR/LF) to be converted to the
platform's convention. "binary safe" means that NUL characters (\0) can
be contained in the string (contrary to C).
> Anyway, thank you for the solution, even though PHP is acting very
> non-intuitively here.
However, it is rather consistent with itself here.
--
Christoph M. Becker