Web lists-archives.com

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

On Wed, Jul 27, 2016 at 12:45 AM, David Spector <news@xxxxxxxxxxxxxxxxxxxxxx
> wrote:

> fwrite($Res,(int)$IDByte,1);

This is wrong. You are first casting $IDByte as int. But fwrite accepts the
second parameter as string. So what it does is convert it back to string.
like "1".

I think what you are looking for is  fprintf($Res, "%c", $IDByte). But it
assumes that $IDByte is lower than 255 otherwise it'll consume more than 1
byte. If its more than one byte how do align them. Do you write on left or
right. These are all encoding stuff.

Unix Hacker

*Innovation distinguishes between follower and leader *
—  Steve Jobs

*An expert is a person who has made all the mistakes that can be made in a
very narrow field.*— Neils Bohr