note 8085 added to fread

From: Date: Sat, 26 Aug 2000 06:22:17 +0000
Subject: note 8085 added to fread
Groups: php.notes 
Request: Send a blank email to php-notes+get-3371@lists.php.net to get a copy of this message
Fread is binary-safe IF AND ONLY IF you don't use magic-quotes. If you do, all null bytes will become \0, and you might get surprising results when unpacking. That is, you would do something like set_magic_quotes_runtime(0); before fread() and something like set_magic_quotes_runtime(get_magic_quotes_gpc()) after. And, after fread, an unpack would be needed, of course. Surprisingly, pack(), however, does not work quite like in Perl (or perhaps I'm just missing something here) - you can't pack an array directly, but instead you'll have to pack each element seperately to the string: foreach ($data as $dec) { $data_output .= pack("C*", $dec); } http://www.php.net/manual/function.fread.php

« previous php.notes (#3371) next »