练习PHP。把ASP的条码生成程序改成了PHP版的。预览:http://free.hanlei.org
[code]
You can test the code:
9787900420206
9787894954947
“0001101001100100100110111101010001101100010101111011101101101110001011”,
“B”=>”0100111011001100110110100001001110101110010000101001000100010010010111”);
$Rencode = array(“1110010″,”1100110″,”1101100″,”1000010″,”1011100″,”1001110″,”1010000″,”1000100″,”1001000″,”1110100″);
$cStart=”101″;
$cMid=”01010″;
$cEnd=”101”;
if($w<2) $w=2;
if($h<20) $h=20;
$cWidth=$w;
$cHeight=$h;
if(strlen($code)!=13){ echo "THS CODE MUST BE 13 NUMBER!"; exit();}
for($i=0;$i<12;$i++)
{
if(is_numeric(substr($code,$i,1))){
if($i % 2!=0)
$rsum=$rsum+(int)(substr($code,$i,1));
else
$lsum=$lsum+(int)(substr($code,$i,1));
}
else{
echo "MUST INPUT NUMBER!";
exit();
}
}
if(10-(((int)$rsum*3+(int)$lsum) % 10) != (int)(substr($code,12,1))){
echo "ERROR CODE!";
exit();
}
$barcode=$cStart;
$Lmethod=substr($code,0,1);
for($i=1;$i<7;$i++){
$barcode = $barcode . substr($Dict[substr($Guide[$Lmethod-1],$i-1,1)],(7*(int)substr($code,$i,1)),7);
}
$barcode=$barcode . $cMid;
for($i=7;$i<13;$i++){
$barcode = $barcode . $Rencode[substr($code,$i,1)];
}
$barcode=$barcode . $cEnd;
$fg="#000000";
$bg="#ffffff";
echo "
for($x=0;$x
“;
}
echo “
echo substr($code,0,1);
echo “
“;
for($x=0;$x<6;$x++){
echo "
echo substr($code,$x+1,1);
echo “
“;
echo “
echo substr($code,$x+7,1);
echo “
“;
}
echo “
“;
echo “
“;
echo “
“;
}
if(isset($_POST[‘bcode’]))
ean13($_POST[‘bcode’],2,100);
else
ean13(“9787894954947”,2,100);
?>
[/code]
转载请注明:HANLEI'BLOG » PHP版条码生成器