PHP5生成条形码的简单实例
该软件支持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://pic4.phprm.com/2013/09/04/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代码:
- <img src=test.php?codebar=BCGcode39&text=20090729>
PHP5生成条形码效果图:
498)this.width=498; onmousewheel = javascript:return big(this) alt=运行实例效果图 src=http://pic4.phprm.com/2013/09/04/20130904094617379.jpg width=665 height=186>
PHP5生成条形码test.php代码:
<?php // Including all required classes
在运行过程中出现异常;
throw $e; //重掷异常
}
}
?﹥
教程链接:http://www.phprm.com/frame/php1003361.html
随意转载~但请保留教程地址★