(zz071028)用PHP以16进制显示文件

<?php

if( count($argv) < 2 ){

print "usage: $argv[0] filename";

return;

}

$filename = $argv[1];

$filesize = filesize( $filename );

$file = fopen( $filename, 'rb');

$contents = fread($file, filesize( $filename ));

for($i=0;    $i <$filesize;    $i++) {

printf( "%02x",  ord( $contents[$i]) );

}

fclose ( $file );

?>

你可能感兴趣的:(PHP)