UPS跟踪号校验代码
每个快递公司生成的单号大部分带自校验功能。下面的代码实现对UPS单号的正确性校验
function validUPS($tr){
$tr = strtoupper(trim($tr));
if (strlen($tr) == 11)
{
$checknumber = 100 - (substr($tr,1, 1) + substr($tr,3, 1) + substr($tr,5, 1) + substr($tr,7, 1) + substr($tr,9, 1) + 2 * (substr($tr,2, 1) + substr($tr,4, 1) + substr($tr,6, 1) + substr($tr,8, 1)));
if ($checknumber = 10)
{
$checknumber = substr($checknumber,1,1);
}
else if ($checknumber = 65 && $i = 73 && $i = 83 && $i = 10)
{
$checknumber = substr($checknumber,1,1);
}
$r= $checknumber == substr($tr,15, 1);
}else {
$r=false;
}
return $r;
}
关键字:php, substr, chr, else
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!