简体   繁体   中英

PHP Pack Warning: pack(): arguments unused

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?

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.

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]));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM