Re: How to write binary data to a file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


-- 
Shiplu.Mokadd.im
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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux