Re: How to write binary data to a file?

From: Date: Tue, 26 Jul 2016 23:09:15 +0000
Subject: Re: How to write binary data to a file?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-325665@lists.php.net to get a copy of this message
On Wed, Jul 27, 2016 at 12:45 AM, David Spector <news@springtimesoftware.com > 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

« previous php.general (#325665) next »