惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
S
Securelist
MyScale Blog
MyScale Blog
Jina AI
Jina AI
罗磊的独立博客
The Cloudflare Blog
美团技术团队
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
雷峰网
雷峰网
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
博客园 - 聂微东
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
T
Tailwind CSS Blog
Attack and Defense Labs
Attack and Defense Labs
博客园_首页
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Hacker News
The Hacker News
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
D
Docker
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Security Latest
Security Latest
V2EX - 技术
V2EX - 技术
N
News | PayPal Newsroom
Microsoft Security Blog
Microsoft Security Blog

博客园 - 网络隐士

[游戏] 连连看之eBay易趣搞笑版 [.NET之西天取经] (01) 即将踏上去硅谷的班机 张江大厦蒸包子,东湖物业真抠门 淘宝的人工封IP技术真好玩 感叹吴总落户易趣 美国签证二进宫 隐士搞定美国签证惊魂记 eBay之歌(Flash版) 阶乘运算之Python VS Java Python代码高亮显示工具 将GBK汉字转化为拼音的Python小程序 一个小巧的MySQL Shell 一个小巧的Python Shell 根据CDImage.cue产生自动改名命令的Python小程序 繁体中文转换为简体中文的PHP类 简体中文转换为繁体中文的PHP类 GBK汉字转化为拼音或笔画的PHP类 文本间加入任意字符的PHP函数 JavaScript日历
显示code39条形码的PHP类
网络隐士 · 2005-09-13 · via 博客园 - 网络隐士

<?
/***********************************************************************
                       Written by caocao
                       caocao@eastday.com
                       http://nethermit.yeah.net
                       
                       显示code39条形码的类
                       使用方法:
                       $convert=new code39;
                       $str=$convert->decode($str);
***********************************************************************/
class
pattenclass
{
    var
$color
;
    var
$width
;
    function
pattenclass($color,$width
)
    {
        
$this->color=$color
;
        
$this->width=$width
;
    }
}

class

code39
{
    var
$zoom
;
    var
$height
;
    var
$patten
=array();
    function
code39($zoom, $height
)
    {
        
$zoom=intval($zoom
);
        
$this->zoom=$zoom<1||$zoom>20?3:$zoom
;
        
$height=intval($height
);
        
$this->height=$height<1||$height>80?30:$height
;
        
$this->patten[]=new pattenclass("#FFFFFF",1*$this->zoom
);
        
$this->patten[]=new pattenclass("#FFFFFF",3*$this->zoom
);
        
$this->patten[]=new pattenclass("#000000",1*$this->zoom
);
        
$this->patten[]=new pattenclass("#000000",3*$this->zoom
);
    }
    function
makecode($code)
//code39解码
    
{
        switch (
$code
)
        {
            case
"0":return ("202130302"
);
            case
"1":return ("302120203"
);
            case
"2":return ("203120203"
);
            case
"3":return ("303120202"
);
            case
"4":return ("202130203"
);
            case
"5":return ("302130202"
);
            case
"6":return ("203130202"
);
            case
"7":return ("202120303"
);
            case
"8":return ("302120302"
);
            case
"9":return ("203120302"
);
            case
"A":return ("302021203"
);
            case
"B":return ("203021203"
);
            case
"C":return ("303021202"
);
            case
"D":return ("202031203"
);
            case
"E":return ("302031202"
);
            case
"F":return ("203031202"
);
            case
"G":return ("202021303"
);
            case
"H":return ("302021302"
);
            case
"I":return ("203021300"
);
            case
"J":return ("202031302"
);
            case
"K":return ("302020213"
);
            case
"L":return ("203020213"
);
            case
"M":return ("303020212"
);
            case
"N":return ("202030213"
);
            case
"O":return ("302030212"
);
            case
"P":return ("203030212"
);
            case
"Q":return ("202020313"
);
            case
"R":return ("302020312"
);
            case
"S":return ("203020312"
);
            case
"T":return ("202030312"
);
            case
"U":return ("312020203"
);
            case
"V":return ("213020203"
);
            case
"W":return ("313020202"
);
            case
"X":return ("212030203"
);
            case
"Y":return ("312030202"
);
            case
"Z":return ("213030202"
);
            case
"-":return ("212020303"
);
            case
".":return ("312020302"
);
            case
" ":return ("213020302"
);
            case
"*":return ("212030302"
);
            case
"$":return ("212121202"
);
            case
"/":return ("212120212"
);
            case
"+":return ("212021212"
);
            case
"%":return ("202121212"
);
        }
        return (
"212030302"
);
    }
    function
display($code)
//输出单个字符
    
{
        
$output=""
;
        for (
$i=0;$i<9;$i
++)
            
$output.="<td height=".$this->height." bgcolor=".$this->patten[$code[$i]]->color." width=".$this->patten[$code[$i]]->width."></td>"
;
        return
$output
;
    }
    function
decode($code)
//全部输出
    
{
        
$output="<table width=".($this->height/2*(strlen($code)+2)*$this->zoom)." height=".$this->height." border=0 cellspacing=0 cellpadding=0 align=\"center\"><tr>"
;
        
$output.=$this->display($this->makecode("*"
));
        
$output.="<td height=".$this->height." bgcolor=".$this->patten[0]->color." width=".$this->patten[0]->width."></td>"
;
        
$length=strlen($code
);
        for (
$i=0;$i<$length;$i
++)
        {
            
$output.=$this->display($this->makecode($code[$i
]));
            
$output.="<td height=".$this->height." bgcolor=".$this->patten[0]->color." width=".$this->patten[0]->width."></td>"
;
        }
        
$output.=$this->display($this->makecode("*"
));
        
$output.="</tr></table>"
;
        return
$output
;
    }
}
?>