


A simple example of generating barcodes with PHP5_PHP Tutorial
The software supports both PHP4 and PHP5 versions. The PHP5 version is used in this article. Be sure to turn on PHP's GD module before use. This is php_gd2.dll in Windows and gd.so in Linux. Extract the compressed file to Apache and execute http://localhost/barcode/index.php. PHP5 generates barcodes as shown below:
1. Type: Select the barcode type
2. Output: Output image format
3. Thickness: Barcode height
4. Resolution: barcode size
5. Font: text size below the barcode, or no text displayed
6. Text: barcode printed content
Of course, this PHP5 barcode generation program only generates text into barcodes, but it cannot be flexibly embedded in other PHP programs when used. I will compress the test in the package Some adjustments have been made to .php to make it flexible for use in other programs. When running, just pass the barcode type and text to test.php, for example:
http://localhost/barcode/test.php?codebar=BCGcode39&text=20090729
Or run http://localhost/barcode/mytest.php
mytest.php code:
<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><SPAN class=tag-name>img</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>></span></font></strong></span><span><font color="#000000"> </font></span> </li></ol>
<span style="COLOR: #0000ff"></span>PHP5生成条形码效果图:
PHP5 generates barcode test.php code:
<span style="COLOR: #0000ff"><pre class="brush:php;toolbar:false"><ol class="dp-c"> <li class="alt"><span><span><font color="#000000"><?php </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=comment><FONT color=#008200>// Including all required classes </FONT></SPAN><SPAN><FONT color=#000000> </FONT></SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>require</FONT></STRONG></SPAN><SPAN><FONT color=#000000>(</FONT></SPAN><SPAN class=string>'class/BCGFont.php'</SPAN><SPAN><FONT color=#000000>); </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>require</FONT></STRONG></SPAN><SPAN><FONT color=#000000>(</FONT></SPAN><SPAN class=string>'class/BCGColor.php'</SPAN><SPAN><FONT color=#000000>); </FONT></SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>require</FONT></STRONG></SPAN><SPAN><FONT color=#000000>(</FONT></SPAN><SPAN class=string>'class/BCGDrawing.php'</SPAN><SPAN><FONT color=#000000>); </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=comment><FONT color=#008200>/*'BCGcodabar','BCGcode11','BCGcode39','BCGcode39extended','BCGcode93', </FONT></SPAN> </SPAN><LI class=alt><SPAN><SPAN class=comment><FONT color=#008200>'BCGcode128','BCGean8','BCGean13','BCGisbn','BCGi25','BCGs25','BCGmsi', </FONT></SPAN><FONT color=#000000> </FONT></SPAN><LI><SPAN><SPAN class=comment><FONT color=#008200>'BCGupca','BCGupce','BCGupcext2','BCGupcext5','BCGpostnet','BCGothercode'*/</FONT></SPAN><SPAN><FONT color=#000000> </FONT></SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=vars><FONT color=#dd0000>$codebar</FONT></SPAN><SPAN><FONT color=#000000> = </FONT></SPAN><SPAN class=vars><FONT color=#dd0000>$_REQUEST</FONT></SPAN><SPAN><FONT color=#000000>[</FONT></SPAN><SPAN class=string>'codebar'</SPAN><SPAN><FONT color=#000000>]; </FONT></SPAN><SPAN class=comment><FONT color=#008200>//该软件支持的所有编码,只需调整$codebar参数即可。 </FONT></SPAN><SPAN><FONT color=#000000> </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=comment><FONT color=#008200>// Including the barcode technology </FONT></SPAN><SPAN><FONT color=#000000> </FONT></SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>include</FONT></STRONG></SPAN><SPAN><FONT color=#000000>(</FONT></SPAN><SPAN class=string>'class/'</SPAN><SPAN><FONT color=#000000>.</FONT></SPAN><SPAN class=vars><FONT color=#dd0000>$codebar</FONT></SPAN><SPAN><FONT color=#000000>.</FONT></SPAN><SPAN class=string>'.barcode.php'</SPAN><SPAN><FONT color=#000000>); </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=comment><FONT color=#008200>// Loading Font </FONT></SPAN><SPAN><FONT color=#000000> </FONT></SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=vars><FONT color=#dd0000>$font</FONT></SPAN><SPAN><FONT color=#000000> = </FONT></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>new</FONT></STRONG></SPAN><SPAN><FONT color=#000000> BCGFont(</FONT></SPAN><SPAN class=string>'./class/font/Arial.ttf'</SPAN><SPAN><FONT color=#000000>, 10); </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=comment><FONT color=#008200>// The arguments are R, G, B for color. </FONT></SPAN><SPAN><FONT color=#000000> </FONT></SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=vars><FONT color=#dd0000>$color_black</FONT></SPAN><SPAN><FONT color=#000000> = </FONT></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>new</FONT></STRONG></SPAN><SPAN><FONT color=#000000> BCGColor(0, 0, 0); </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=vars><FONT color=#dd0000>$color_white</FONT></SPAN><SPAN><FONT color=#000000> = </FONT></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>new</FONT></STRONG></SPAN><SPAN><FONT color=#000000> BCGColor(255, 255, 255); </FONT></SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=vars><FONT color=#dd0000>$code</FONT></SPAN><SPAN><FONT color=#000000> = </FONT></SPAN><SPAN class=keyword><STRONG><FONT color=#006699>new</FONT></STRONG></SPAN><SPAN><FONT color=#000000> </FONT></SPAN><SPAN class=vars><FONT color=#dd0000>$codebar</FONT></SPAN><SPAN><FONT color=#000000>(); </FONT></SPAN></SPAN><LI><SPAN></SPAN><SPAN class=vars><FONT color=#dd0000>$code</FONT></SPAN><SPAN><FONT color=#000000>->setScale(2); </font></span><span class="comment"><font color="#008200">// Resolution </font></span><span><font color="#000000"> </font></span></span></li> <li class="alt"> <span></span><span class="vars"><font color="#dd0000">$code</font></span><span><font color="#000000">->setThickness(30); </font></span><span class="comment"><font color="#008200">// Thickness </font></span><span><font color="#000000"> </font></span> </li> </ol>
throw $e; //Rethrow exception
}
}
?﹥

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

CrystalDiskInfo is a software used to check computer hardware devices. In this software, we can check our own computer hardware, such as reading speed, transmission mode, interface, etc.! So in addition to these functions, how to use CrystalDiskInfo and what exactly is CrystalDiskInfo? Let me sort it out for you! 1. The Origin of CrystalDiskInfo As one of the three major components of a computer host, a solid-state drive is the storage medium of a computer and is responsible for computer data storage. A good solid-state drive can speed up file reading and affect consumer experience. When consumers receive new devices, they can use third-party software or other SSDs to

Regarding Llama3, new test results have been released - the large model evaluation community LMSYS released a large model ranking list. Llama3 ranked fifth, and tied for first place with GPT-4 in the English category. The picture is different from other benchmarks. This list is based on one-on-one battles between models, and the evaluators from all over the network make their own propositions and scores. In the end, Llama3 ranked fifth on the list, followed by three different versions of GPT-4 and Claude3 Super Cup Opus. In the English single list, Llama3 overtook Claude and tied with GPT-4. Regarding this result, Meta’s chief scientist LeCun was very happy and forwarded the tweet and

When we use the Edge browser, sometimes incompatible software attempts to be loaded together, so what is going on? Let this site carefully introduce to users how to solve the problem of trying to load incompatible software with Edge. How to solve an incompatible software trying to load with Edge Solution 1: Search IE in the start menu and access it directly with IE. Solution 2: Note: Modifying the registry may cause system failure, so operate with caution. Modify registry parameters. 1. Enter regedit during operation. 2. Find the path\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Micros

The meaning and difference of PHP version NTS PHP is a popular server-side scripting language that is widely used in the field of web development. There are two main versions of PHP: ThreadSafe(TS) and Non-ThreadSafe(NTS). On the official website of PHP, we can see two different PHP download versions, namely PHPNTS and PHPTS. So, what does PHP version NTS mean? What is the difference between it and the TS version? Next,

PhotoshopCS is the abbreviation of Photoshop Creative Suite. It is a software produced by Adobe and is widely used in graphic design and image processing. As a novice learning PS, let me explain to you today what software photoshopcs5 is and how to use photoshopcs5. 1. What software is photoshop cs5? Adobe Photoshop CS5 Extended is ideal for professionals in film, video and multimedia fields, graphic and web designers who use 3D and animation, and professionals in engineering and scientific fields. Render a 3D image and merge it into a 2D composite image. Edit videos easily

The Chrome browser is currently the browser with the largest number of users and high praise, and is committed to providing users with a comprehensive and fast experience. Some netizens feel that the old version is still easier to use after updating Google Chrome. If they want to downgrade the version of Google Chrome, what should they do? Let’s take a look at the detailed operation method of downgrading Google Chrome! The specific method of downgrading Chrome is to close the Chrome process, open the directory where chrome.exe is located (Application), delete chrome.exe, rename old_chrome.exe to chrome.exe, and delete the \UserData\Default\Web Data file (do not delete this

With the popularity of Douyin, more and more companies and individuals have begun to use Douyin for marketing. As an important tool for Douyin marketing, the Douyin matrix management system has also received widespread attention. So, which version of Douyin matrix management system is recommended? This article will answer this question for you and introduce how to play Douyin matrix marketing. 1. Which version of Douyin matrix management system is recommended? There are many versions of the Douyin matrix management system. The following versions are currently popular on the market: Douyin’s official version of the matrix management system is specially designed for companies with certain operating experience and budget, and can realize multi-account management, data Analysis and material library functions. This system provides an efficient way to manage Douyin accounts and helps companies better understand their operational data to better
