how to display the binary form of the file with php?

From: Date: Sat, 13 Aug 2016 01:08:20 +0000
Subject: how to display the binary form of the file with php?
Groups: php.general 
Request: Send a blank email to php-general+get-325672@lists.php.net to get a copy of this message
Every file can be displayed in the binary form no matter which encoding the file is.(utf-8 gbk iso-8859-1 latin-1) xxd filename can do the trick. Now i want to do with php,here is my try. <?php $target="test.txt"; $file_handle = fopen($target, "rb"); while (!feof($file_handle)) { $byte = fread($file_handle,1); echo $byte; } fclose($file_handle ); ?> It is unlucky that all the character is not displayed on binary form,how to fix echo $byte ?

« previous php.general (#325672) next »