国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

thinkPHP框架實現(xiàn)生成條形碼的方法示例

2024-05-05 00:04:07
字體:
來源:轉載
供稿:網友

本文實例講述了thinkPHP框架實現(xiàn)生成條形碼的方法。分享給大家供大家參考,具體如下:

在做之前我們先下載barcode類,想下載該類可以點擊此處本站下載

我們在后臺寫一個方法代碼如下:

//生成條形碼public function barcode(){  import('@.ORG.Util.barcode.BCGFontFile');//字體類  import('@.ORG.Util.barcode.BCGColor');//字體顏色類  import('@.ORG.Util.barcode.BCGDrawing');  import('@.ORG.Util.barcode.BCGcode39');  $text = $_GET['text'];  $texts = isset($text)?$text:'00000000000';  $color_black = new /BCGColor(0,0,0);  $color_white = new /BCGColor(255,255,255);  $drawException = null;  try {    $code = new /BCGcode39();    $code->setScale(2);    $code->setThickness(30);    $code->setForegroundColor($color_black);    $code->setBackgroundColor($color_white);    $code->parse($texts);  } catch(Exception $exception) {    $drawException = $exception;  }  $drawing = new /BCGDrawing('', $color_white);  if($drawException) {    $drawing->drawException($drawException);  } else {    $drawing->setBarcode($code);    $drawing->draw();  }  header('Content-Type: image/png');  header('Content-Disposition: inline; filename="barcode.png"');  $drawing->finish(/BCGDrawing::IMG_FORMAT_PNG);}

在前臺直接調用:

<img src="{:U('ContractCommonApply/barcode')}/text/{$res[0]['ContractCode']}" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";">	
<script type="text/javascript" language="JavaScript">  document.writeln("<img src=/目錄/test_1D.php?text=內容 />");</script>

希望本文所述對大家基于ThinkPHP框架的PHP程序設計有所幫助。


注:相關教程知識閱讀請移步到PHP教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 常宁市| 措美县| 资阳市| 博野县| 临潭县| 基隆市| 金昌市| 梁山县| 竹北市| 西城区| 白玉县| 宁蒗| 台中市| 洪雅县| 四川省| 镇平县| 德清县| 张家川| 潮安县| 济源市| 灵寿县| 治多县| 荥阳市| 琼海市| 商都县| 镇雄县| 额济纳旗| 大竹县| 洛浦县| 搜索| 孝义市| 云安县| 莆田市| 龙泉市| 观塘区| 西峡县| 普宁市| 孟津县| 南丰县| 江门市| 龙川县|