[英]PHP Pack Warning: pack(): arguments unused
I am getting 我正进入(状态
Warning: pack(): 1 arguments unused in 警告:pack():1个未使用的参数
$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?
应该是十六进制吗?
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, ie the compiler will transform the value from hexadecimals to binary - there is no need to use pack
on it. 如果使用
0x77
,则已经有一个数值,值为77h,即编译器会将值从十六进制转换为二进制-无需在其上使用pack
。
If you really want to use the 0x77,0x99
notation, then put the notation in quotes and use the following: 如果您确实要使用
0x77,0x99
表示法,则将该表示法放在引号中并使用以下命令:
$hex="0x77,0x99";
preg_match_all("/0x([0-9A-F]{2})/i", $hex, $out);
$data = pack("H*", join($out[1]));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.