使用php bin2hex函数读取bin文件
我正在尝试读取一个 bin 文件,其中包含很多两个 4 字节数字,我想读取这些数字并将其转换为十六进制数字,然后将其打印到屏幕上......但希望我有我有点难以理解这个问题。这是我到目前为止阅读示例和文档所得到的。
<?php
$handle = @fopen("files/bigbin1.bin", "r");
if ($handle) {
while (!feof($handle)) {
$hex = bin2hex($handle);
}
fclose($handle);
}
print_r($hex);
?>
我 95% 确定错误是在将 $handle 传递给 tbin2hex 时发生的。但这是我第一次阅读 bin 文件,我有点迷失了。在某些时候的总体目标是将 bin 文件读入数据库,但我只是想弄清楚该文件在屏幕上的样子。
I am trying to read a bin file that contains a lots of two 4-byte numbers in it, which I want to read and convert to hex numbers that is then going to be printed to the screen.... hopefully however I am having a little trouble getting my head around this one. this is what I have so far from reading examples and documentation..
<?php
$handle = @fopen("files/bigbin1.bin", "r");
if ($handle) {
while (!feof($handle)) {
$hex = bin2hex($handle);
}
fclose($handle);
}
print_r($hex);
?>
I am 95% sure the error is in passing $handle over to tbin2hex.. but this being my first ever reading of a bin file I am slightly lost. the overall goal at some point will be to read the bin file into the database however I am just trying to figure out what this file looks like on screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:您还应该避免使用
@
它会使调试变得非常令人沮丧。EDIT: Also you should avoid using
@
it can make debugging extremely frustrating.