Web lists-archives.com

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




Shiplu,

fprintf($Res, "%c", $IDByte);

worked. It actually wrote a byte containing 0b1. Whew.

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).

Anyway, thank you for the solution, even though PHP is acting very non-intuitively here.

I consider this question closed now: fwrite can only write strings. Thanks to everyone for the responses.

David

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