下面的就是生成EAN_13标准的条码的PHP方法,需要php+gd 环境 
  复制代码 代码如下:<?
function EAN_13($code) {
  //一个单元的宽度
  $lw = 2;
  //条码高 
  $hi = 100;
  // the guide code is no coding,is used to show the left part coding type//
  // Array guide is used to record the EAN_13 is left part coding type//
  $Guide = array(1=>'AAAAAA','AABABB','AABBAB','ABAABB','ABBAAB','ABBBAA','ABABAB','ABABBA','ABBABA');
  $Lstart ='101';
  $Lencode = array("A" => array('0001101','0011001','0010011','0111101','0100011','0110001','0101111','0111011','0110111','0001011'),
                   "B" => array('0100111','0110011','0011011','0100001','0011101','0111001','0000101','0010001','0001001','0010111'));
  $Rencode = array('1110010','1100110','1101100','1000010','1011100',
                   '1001110','1010000','1000100','1001000','1110100');    

  $center = '01010';

  $ends = '101';
  if ( strlen($code) != 13 )
   { die("UPC-A Must be 13 digits."); }
$lsum =0;
$rsum =0;
  for($i=0;$i<(strlen($code)-1);$i++)
  {
    if($i % 2)
{
 // $odd += $ncode[$x]
  $lsum +=(int)$code[$i];
 }else{
  $rsum +=(int)$code[$i];
 }

  }
  $tsum = $lsum*3 + $rsum;
    if($code[12] != (10-($tsum % 10)))
{
   die("the code is bad!");
    } 

 // echo $Guide[$code[0]];
  $barcode = $Lstart;
  for($i=1;$i<=6;$i++)
  {
    $barcode .= $Lencode [$Guide[$code[0]][($i-1)]] [$code[$i]];
  }
  $barcode .= $center;

  for($i=7;$i<13;$i++)
  {
    $barcode .= $Rencode[$code[($i)]] ;
  }
  $barcode .= $ends;

    $img = ImageCreate($lw*95+60,$hi+30);
  $fg = ImageColorAllocate($img, 0, 0, 0);
  $bg = ImageColorAllocate($img, 255, 255, 255);
  ImageFilledRectangle($img, 0, 0, $lw*95+60, $hi+30, $bg);
  $shift=10;
  for ($x=0;$x<strlen($barcode);$x++) {
    if (($x<4) || ($x>=45 && $x<50) || ($x >=92)) 
  { 
    $sh=10; 
  } else { 
    $sh=0; 
  }
    if ($barcode[$x] == '1') 

  $color = $fg;
    } else { 
  $color = $bg; 
}
    ImageFilledRectangle($img, ($x*$lw)+30,5,($x+1)*$lw+29,$hi+5+$sh,$color);
  }
  /* Add the Human Readable Label */
  ImageString($img,5,20,$hi+5,$code[0],$fg);
  for ($x=0;$x<6;$x++) {
    ImageString($img,5,$lw*(8+$x*6)+30,$hi+5,$code[$x+1],$fg);
    ImageString($img,5,$lw*(53+$x*6)+30,$hi+5,$code[$x+7],$fg);
  }
 // ImageString($img,4,$lw*95+17,$hi-5,$code[12],$fg);
  /* Output the Header and Content. */
  header("Content-Type: image/png");
  ImagePNG($img);

}

EAN_13('6901028055048');

?> 

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。