dongyi9330 2014-08-28 22:53 采纳率: 100%
浏览 296
已采纳

PHP Pack警告:pack():参数未使用

I am getting

Warning: pack(): 1 arguments unused in

 $vector = pack("H*",0x77,0x99); 




 $vector = pack("H*","4A","76");  // with quotes also give same warning

but if i use only one value there is no Warning

 $vector = pack("H*",0x77); 

Do anybody know about this warning ?

what value should i pass to pack . is it should be hex?

  • 写回答

1条回答 默认 最新

  • dsxay48646 2014-08-29 11:07
    关注

    You should pass it hexadecimals in a string, like so:

    $vector = pack("H*", "7799");
    

    If you use 0x77 you already have a numeric value with the value 77h, i.e. the compiler will transform the value from hexadecimals to binary - there is no need to use pack on it.

    If you really want to use the 0x77,0x99 notation, then put the notation in quotes and use the following:

    $hex="0x77,0x99";
    preg_match_all("/0x([0-9A-F]{2})/i", $hex, $out);
    $data = pack("H*", join($out[1]));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器