suchen
Heimphp教程php手册PHP5生成条形码的简单实例

PHP5生成条形码的简单实例

Jun 13, 2016 am 11:03 AM
php5实例支持Ja条形码版本生成Gebrauchtvon简单软件

该软件支持PHP4和PHP5两个版本,本文中使用的是PHP5的版本。在使用前注意要将PHP的GD模块开启。在Windows中为php_gd2.dll,Linux中为gd.so。将压缩文件解压到Apache,执行http://localhost/barcode/index.php。PHP5生成条形码见下图:

1. Type:选择条形码类型

2. Output:输出的图片格式

3. Thickness:条形码高度

4. Resolution:条形码大小

5. Font:条形码下方的文字大小,也可不显示文字

6. Text:条形码打印的内容

498)this.width=498;' onmousewheel = 'javascript:return big(this)' alt=条码效果 src="http://www.bkjia.com/uploadfile/2013/0904/20130904094617982.jpg" width=615 height=557>

当然,这个PHP5生成条形码程序只是将文字生成为条形码,但使用时不能灵活将其嵌入其他PHP程序,我将压缩包里面的test.php做了一些调整,使其能灵活的用于其他程序。运行时只需将条码类型和文字传给test.php即可,例如:
http://localhost/barcode/test.php?codebar=BCGcode39&text=20090729

或运行 http://localhost/barcode/mytest.php

mytest.php代码:

<span style="COLOR: #0000ff"><pre class="brush:php;toolbar:false"><ol class="dp-xml"><li class="alt"><span><strong><font color="#006699"><span class="tag"><span class="tag-name">img</span></span></font></strong><span><font color="#000000"> </font></span><span class="attribute"><font color="#ff0000">src</font></span><span><font color="#000000">=</font></span><span class="attribute-value">"test.php?codebar=BCGcode39&text=20090729"</span><span class="tag"><strong><font color="#006699">></font></strong></span><span><font color="#000000"> </font></span></span></li></ol>
<span style="COLOR: #0000ff"></span>PHP5生成条形码效果图:

498)this.width=498;' onmousewheel = 'javascript:return big(this)' alt=运行实例效果图 src="http://www.bkjia.com/uploadfile/2013/0904/20130904094617379.jpg" width=665 height=186>

PHP5生成条形码test.php代码:

<span style="COLOR: #0000ff"><pre class="brush:php;toolbar:false"><ol class="dp-c">
<li class="alt"><span><span><font color="#000000"><?php  </FONT></font></span></span></li>
<li>
<span></span><span class="comment"><font color="#008200">// Including all required classes </font></span><span><font color="#000000"> </font></span>
</li>
</ol>
  • require('class/BCGFont.php');  
  • require('class/BCGColor.php');  
  • require('class/BCGDrawing.php');  
  • /*'BCGcodabar','BCGcode11','BCGcode39','BCGcode39extended','BCGcode93',  
  • 'BCGcode128','BCGean8','BCGean13','BCGisbn','BCGi25','BCGs25','BCGmsi',  
  • 'BCGupca','BCGupce','BCGupcext2','BCGupcext5','BCGpostnet','BCGothercode'*/ 
  • $codebar = $_REQUEST['codebar']; //该软件支持的所有编码,只需调整$codebar参数即可。  
  • // Including the barcode technology  
  • include('class/'.$codebar.'.barcode.php');  
  • // Loading Font  
  • $font = new BCGFont('./class/font/Arial.ttf', 10);  
  • // The arguments are R, G, B for color.  
  • $color_black = new BCGColor(0, 0, 0);  
  • $color_white = new BCGColor(255, 255, 255);  
  • $code = new $codebar();  
  • $code->setScale(2); // Resolution  
  • $code->setThickness(30); // Thickness  
  • $code->setForegroundColor($color_black); // Color of bars  
  • $code->setBackgroundColor($color_white); // Color of spaces  
  • $code->setFont($font); // Font (or 0)  
  • $text = $_REQUEST['text']; //PHP5生成条形码将要数据的内容  
  • $code->parse($text);  
  • /* Here is the list of the arguments  
  • 1 - Filename (empty : display on screen)  
  • 2 - Background color */ 
  • $drawing = new BCGDrawing(''$color_white);  
  • $drawing->setBarcode($code);  
  • $drawing->draw();  
  • // Header that says it is an image (remove it if you save the barcode to a file)  
  • header('Content-Type: image/png');  
  • // Draw (or save) the image into PNG format.  
  • $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);  
  • ?> 
  • 在运行过程中出现异常";
    throw $e; //重掷异常
    }
    }
    ?﹥
    
    


    Stellungnahme
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

    Heiße KI -Werkzeuge

    Undresser.AI Undress

    Undresser.AI Undress

    KI-gestützte App zum Erstellen realistischer Aktfotos

    AI Clothes Remover

    AI Clothes Remover

    Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

    Undress AI Tool

    Undress AI Tool

    Ausziehbilder kostenlos

    Clothoff.io

    Clothoff.io

    KI-Kleiderentferner

    AI Hentai Generator

    AI Hentai Generator

    Erstellen Sie kostenlos Ai Hentai.

    Heißer Artikel

    R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
    4 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Beste grafische Einstellungen
    4 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. So reparieren Sie Audio, wenn Sie niemanden hören können
    4 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: Wie man alles in Myrise freischaltet
    1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌

    Heiße Werkzeuge

    Senden Sie Studio 13.0.1

    Senden Sie Studio 13.0.1

    Leistungsstarke integrierte PHP-Entwicklungsumgebung

    PHPStorm Mac-Version

    PHPStorm Mac-Version

    Das neueste (2018.2.1) professionelle, integrierte PHP-Entwicklungstool

    WebStorm-Mac-Version

    WebStorm-Mac-Version

    Nützliche JavaScript-Entwicklungstools

    MinGW – Minimalistisches GNU für Windows

    MinGW – Minimalistisches GNU für Windows

    Dieses Projekt wird derzeit auf osdn.net/projects/mingw migriert. Sie können uns dort weiterhin folgen. MinGW: Eine native Windows-Portierung der GNU Compiler Collection (GCC), frei verteilbare Importbibliotheken und Header-Dateien zum Erstellen nativer Windows-Anwendungen, einschließlich Erweiterungen der MSVC-Laufzeit zur Unterstützung der C99-Funktionalität. Die gesamte MinGW-Software kann auf 64-Bit-Windows-Plattformen ausgeführt werden.

    VSCode Windows 64-Bit-Download

    VSCode Windows 64-Bit-Download

    Ein kostenloser und leistungsstarker IDE-Editor von Microsoft