【问题标题】:print binary data with php用php打印二进制数据
【发布时间】:2012-10-24 00:14:36
【问题描述】:

我想回显要由我的 http 客户端解析的二进制数据。我正在使用 HTTP GET,我已经尝试过:

<?php
if (isset($_GET['mac'])) {
  if (isset($_GET['f'])) {
    switch ($_GET['f']){
  case 'get_maclist':
      $binarydata = pack("C*", 0x00, 0x00,0x10, 0x2C, 0x1B, 0x16, 0x4C, 0xDF, 0xCB, 0x00,     0x01);

  $header="Content-Disposition: attachment; filename=test.bin;";
  header($header);
  header("Content-Transfer-Encoding: binary");
  echo $binarydata;

我调用的网址:http://MyIP/test.php?mac=ABC&f=get_maclist

但是当使用十六进制编辑器查看二进制文件时,我在文件中收到的内容有所不同。如何正确完成这项工作?

谢谢

【问题讨论】:

  • 它似乎运作良好。执行od -x test.bin 显示0000000 0000 2c10 161b df4c 00cb 0001。与您的预期有何不同?
  • 我想通了。问题出在我的代码中的不同位置,仅仅是因为我忘记了休息;在 switch() 中,它会将与预期不同的数据加载到二进制文件中......

标签: php http get binary


【解决方案1】:

我想通了。问题出在我的代码中的不同位置,仅仅是因为我忘记了休息;在 switch() 中,它会将与预期不同的数据加载到二进制文件中......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-23
    • 1970-01-01
    • 1970-01-01
    • 2011-11-22
    • 1970-01-01
    • 1970-01-01
    • 2019-09-26
    • 2020-05-09
    相关资源
    最近更新 更多