Web lists-archives.com

[PHP] How to write binary data to a file?

Hi all,

All I can find in the PHP Manual for writing raw bytes (unsigned integers) to a file is fwrite. But when I use it, it seems to write characters, not raw bytes. For example, the value 1 (0b1) is actually written as 0x31, not 0x01 as desired. Yes, the fopen was done with the "b" mode specified.

It doesn't work this way in C or C++, and the PHP Manual says nothing about this.

Web searches turn up nothing useful on this subject.

I have posted this question on three PHP fora, and have received only unhelpful or irrelevant answers so far.

System: Windows 8.1, PHP 5.5.10

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php