自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

PHP5生成條形碼的簡(jiǎn)單實(shí)例

開發(fā) 后端
本PHP5生成條形碼的簡(jiǎn)單實(shí)例中使用的是PHP5的版本。在使用前注意要將PHP的GD模塊開啟。在Windows中為php_gd2.dll,Linux中為gd.so。將壓縮文件解壓到Apache。

該軟件支持PHP4和PHP5兩個(gè)版本,本文中使用的是PHP5的版本。在使用前注意要將PHP的GD模塊開啟。在Windows中為php_gd2.dll,Linux中為gd.so。將壓縮文件解壓到Apache,執(zhí)行http://localhost/barcode/index.php。PHP5生成條形碼見下圖:

1. Type:選擇條形碼類型

2. Output:輸出的圖片格式

3. Thickness:條形碼高度

4. Resolution:條形碼大小

5. Font:條形碼下方的文字大小,也可不顯示文字

6. Text:條形碼打印的內(nèi)容

條碼效果

當(dāng)然,這個(gè)PHP5生成條形碼程序只是將文字生成為條形碼,但使用時(shí)不能靈活將其嵌入其他PHP程序,我將壓縮包里面的test.php做了一些調(diào)整,使其能靈活的用于其他程序。運(yùn)行時(shí)只需將條碼類型和文字傳給test.php即可,例如:
http://localhost/barcode/test.php?codebar=BCGcode39&text=20090729

或運(yùn)行 http://localhost/barcode/mytest.php

mytest.php代碼:

  1. <img src="test.php?codebar=BCGcode39&text=20090729"> 
PHP5生成條形碼效果圖:

運(yùn)行實(shí)例效果圖

PHP5生成條形碼test.php代碼:

  1. <?php  
  2. // Including all required classes  
  3. require('class/BCGFont.php');  
  4. require('class/BCGColor.php');  
  5. require('class/BCGDrawing.php');  
  6. /*'BCGcodabar','BCGcode11','BCGcode39','BCGcode39extended','BCGcode93',  
  7. 'BCGcode128','BCGean8','BCGean13','BCGisbn','BCGi25','BCGs25','BCGmsi',  
  8. 'BCGupca','BCGupce','BCGupcext2','BCGupcext5','BCGpostnet','BCGothercode'*/ 
  9. $codebar = $_REQUEST['codebar']; //該軟件支持的所有編碼,只需調(diào)整$codebar參數(shù)即可。  
  10. // Including the barcode technology  
  11. include('class/'.$codebar.'.barcode.php');  
  12. // Loading Font  
  13. $font = new BCGFont('./class/font/Arial.ttf', 10);  
  14. // The arguments are R, G, B for color.  
  15. $color_black = new BCGColor(0, 0, 0);  
  16. $color_white = new BCGColor(255, 255, 255);  
  17. $code = new $codebar();  
  18. $code->setScale(2); // Resolution  
  19. $code->setThickness(30); // Thickness  
  20. $code->setForegroundColor($color_black); // Color of bars  
  21. $code->setBackgroundColor($color_white); // Color of spaces  
  22. $code->setFont($font); // Font (or 0)  
  23. $text = $_REQUEST['text']; //PHP5生成條形碼將要數(shù)據(jù)的內(nèi)容  
  24. $code->parse($text);  
  25. /* Here is the list of the arguments  
  26. 1 - Filename (empty : display on screen)  
  27. 2 - Background color */ 
  28. $drawing = new BCGDrawing(''$color_white);  
  29. $drawing->setBarcode($code);  
  30. $drawing->draw();  
  31. // Header that says it is an image (remove it if you save the barcode to a file)  
  32. header('Content-Type: image/png');  
  33. // Draw (or save) the image into PNG format.  
  34. $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);  
  35. ?> 
在運(yùn)行過(guò)程中出現(xiàn)異常";
throw $e; //重?cái)S異常
}
}
?﹥

【編輯推薦】

  1. PHP 5中新增加日期(date)函數(shù)的常量簡(jiǎn)介
  2. 在PHP中如何判斷AJAX請(qǐng)求
  3. 如何書寫安全的PHP代碼
  4. PHP5中的異常處理詳解
  5. 實(shí)戰(zhàn)PHP5+Apache2.2+MySQL5.1配置經(jīng)歷
責(zé)任編輯:彭凡 來(lái)源: cnblogs
相關(guān)推薦

2012-06-14 13:09:50

PHP

2024-09-30 10:18:51

2023-08-15 19:24:37

Python條形碼

2011-07-07 16:53:56

iOS 條形碼掃描

2009-11-24 17:01:39

PHP5多重繼承

2011-12-27 20:33:40

移動(dòng)應(yīng)用

2015-10-28 13:33:50

二維碼條形碼掃描源碼

2012-03-19 09:16:02

JavajZebra

2009-10-19 13:34:18

VB.NET條形碼編程

2009-12-03 13:50:16

PHP5異常處理

2009-11-23 20:00:25

PHP5接口PHP5抽象類

2012-05-25 10:26:18

JavaAspose.BarC

2015-07-22 09:15:37

物聯(lián)網(wǎng)條形碼

2009-03-16 16:08:09

PHP異常

2016-03-09 10:03:25

RFID技術(shù)條形碼二維碼

2011-03-11 14:02:55

LAMP安裝PHP5

2009-11-18 18:33:23

Linux PHP5安

2009-11-24 16:28:41

PHP5魔術(shù)函數(shù)

2009-11-23 13:27:22

PHP5指針

2019-03-08 08:55:16

PHP7PHP5web安全
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)