我在PHP中使用pack()时遇到了一些问题
$currencypair = "EUR/USD"; $buy_sell = "buy"; $alert_device_token =array("a","a","b"); $message = "Your " . $currencypair . " " . $buy_sell . " alert price has been reached!"; $payload['aps'] = array ( 'alert' => $message,'badge' => 1,'sound' => 'default' ); $payload = json_encode($payload); foreach ($alert_device_token as $alert_device) { $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*',str_replace(' ','',$alert_device)) . chr(0) . chr(strlen($payload)) . $payload; echo $apnsMessage; }
现在有时我会得到以下警告,运行相同的代码 –
Warning: pack() [function.pack]: Type H: illegal hex digit g in /code/FR2BVl
虽然非法的十六进制数字不变.有关此警告的任何想法以及删除它的方法.
现场检查here