recherche

通过 PHP 生成 一维码
此代码来自  http://www.nixiaofeng.com/110.html

<?php$code = $_GET['code'];if ($code != "") {    if (!is_numeric($code)) die('输入的不是数字');    if (strlen($code) < 12 || strlen($code) > 13) die('条码长度不正确');    if (strlen($code) == 12) {        // 计算校验位        $lsum = 0;        $rsum = 0;        for($i=1; $i<=strlen($code); $i++) {            if($i % 2) {                $lsum += (int)$code[$i-1];            }else{                $rsum += (int)$code[$i-1];            }        }        $tsum = $lsum + $rsum * 3;        $chkdig = 10 - ($tsum % 10);        if ($chkdig == 10) $chkdig = 0;        $code .= $chkdig;    }    // 定义起始付    $start = '101';    // 定义中止符    $end = '101';    // 定义中间分隔符    $center = '01010';    // 定义左资料码    $Guide = array(0=>'AAAAAA','AABABB','AABBAB','AABBBA','ABAABB','ABBAAB','ABBBAA','ABABAB','ABABBA','ABBABA');    // 定义左侧码,分为“A”、“B”两种    $Lencode = array("A" => array('0001101','0011001','0010011','0111101','0100011','0110001','0101111','0111011','0110111','0001011'),    "B" => array('0100111','0110011','0011011','0100001','0011101','0111001','0000101','0010001','0001001','0010111'));    // 定义右侧码,统一为“C”编码    $Rencode = array('1110010','1100110','1101100','1000010','1011100','1001110','1010000','1000100','1001000','1110100');         // 编码起始符    $barcode = $start;    // 编码左资料位    for($i=1; $i<=6; $i++) {        $barcode .= $Lencode[$Guide[$code[0]][($i-1)]][$code[$i]];    }         // 编码中间分隔符    $barcode .= $center;         // 编码右资料位    for($i=7; $i<13; $i++) {        $barcode .= $Rencode[$code[($i)]];    }         // 编码中止符    $barcode .= $end;    // 定义每个条码单元的宽度和高度,单位是像素    $width = 2;    $height = 40;         // 定义起始符、中止符、中间分隔符的高度增量    $increment = 10;         // 创建方形(×95是因为整个条码共95个单元,+60和+30是给条码图片周围留空白边框)    $img = ImageCreate($width*95+60,$height+30);  // 目前这个方形是透明的         // “1”的颜色(黑)与“0”的颜色(白)    $fg = ImageColorAllocate($img, 0, 0, 0);    $bg = ImageColorAllocate($img, 255, 255, 255);         // 以“0”的颜色(白色),填充整个方形    ImageFilledRectangle($img, 0, 0, $width*95+60, $height+30, $bg);         // 循环编码后的每一个单元,输出条码图形    for ($x=0; $x<strlen($barcode); $x++) {        // ($x<4) 为起始符,($x>=92)为中止符,($x>=45 && $x<50)为中间分隔符        // 这3个需要将高度增加        if (($x<4) || ($x>=45 && $x<50) || ($x>=92)) {            $increment = 10;        } else {            $increment = 0;        }        // 当编码值为“1”时,输出黑色;当编码值为“0”时,输出白色        if ($barcode[$x] == '1') {            $color = $fg;        } else {            $color = $bg;        }        ImageFilledRectangle($img, ($x*$width)+30,5,($x+1)*$width+29,$height+$increment,$color);    }    ImageString($img, 5, 20, $height+5, $code[0], $fg);    for ($x=0; $x<6; $x++) {        // 左侧识别码        ImageString($img, 5, $width*(8+$x*6)+30, $height+5, $code[$x+1], $fg);        // 右侧识别码        ImageString($img, 5, $width*(53+$x*6)+30, $height+5, $code[$x+7], $fg);    }    header("Content-Type: image/jpeg");    ImageJPEG($img, "", 100);}?><form action="?">输入EAN-13条形码(如果输入12位长度,将自动计算校验位)<input type="text" name="code"> <input type="submit" value="生成条码图片"></form>


透过 PHP 生成 一维码

Déclaration
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
html的width是什么意思html的width是什么意思Jun 03, 2021 pm 02:15 PM

在html5中,width的意思是宽度,width属性定义元素内容区的宽度,在内容区外面可以增加内边距、边框和外边距,只需要给元素设置“元素{width:数值}”即可。

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code<form name="myform"

在Visual Studio Code中编辑Unity项目,您现在可以开始了在Visual Studio Code中编辑Unity项目,您现在可以开始了Aug 08, 2023 am 10:21 AM

Microsoft发布了VisualStudioCode的Unity扩展预览版。这个新的Unity扩展将允许您编写和调试Unity游戏。这个新的Unity扩展带来了VisualStudio和VisualStudioToolsforUnity上已经提供的一些流行功能,使VisualStudioCode中的C#更好地进行Unity开发。目前,适用于VSCode的Unity扩展提供以下内容:一个Unity调试器,用于调试您的Unity编辑器和Unity播放器。特定于Unity的C#分析器和重构。Uni

CSS 维度属性详解:height 和 widthCSS 维度属性详解:height 和 widthOct 21, 2023 pm 12:42 PM

CSS维度属性详解:height和width在前端开发中,CSS是一种强大的样式定义语言。其中,height和width是两个最基本的维度属性,用于定义元素的高度和宽度。本文将对这两个属性进行详细解析,并提供具体的代码示例。一、height属性height属性用于定义元素的高度。可以使用像素(pixel)、百分比(percentage)或者

css表示width值有哪些方法css表示width值有哪些方法Nov 13, 2023 pm 05:47 PM

方法有像素值、百分比、em单位、rem单位、vw/vh单位、auto、fit-content、min-content、max-content。详细介绍:1、像素值(px):像素值是固定的,不论屏幕分辨率如何变化,它的宽度都是不变的。例如:width: 300px;2、百分比(%):百分比宽度是相对于父元素的宽度的。例如:width: 50%;3、em单位等等。

Microsoft正在推出Windows 11 23H2版本到带有Copilot的发布预览频道Microsoft正在推出Windows 11 23H2版本到带有Copilot的发布预览频道Sep 28, 2023 pm 07:17 PM

每个人都在期待今天的Windows1123H2发布。事实上,Microsoft刚刚启动了对发布预览版的更新,这是正式发布阶段之前最接近的频道。被称为Build22631的Microsoft表示,他们正在推出新的更名聊天应用程序,电话链接和一起玩小部件,这些小部件在过去几个月中已在其他内部渠道中进行了测试。“这个新的更新将具有与Windows11版本22H2相同的服务分支和代码库,并将与所有新宣布的功能累积,包括Windows中的Copilot(预览版),”Microsoft承诺。雷德蒙德官员进一

iframe中width什么意思iframe中width什么意思Sep 19, 2023 pm 12:00 PM

iframe中width是指定框架的宽度的意思,可以控制iframe框架在页面中的宽度展示。width可以接受的值:1、固定像素值,width="300px",框架宽度将始终保持不变,无论浏览器窗口的大小如何变化;2、百分比值,width="50%",框架的宽度将根据其父元素的宽度进行自适应调整;3、自动值,width="auto",框架的宽度将根据其内容的宽度进行自适应调整。

如何在jQuery中移除元素的height属性?如何在jQuery中移除元素的height属性?Feb 27, 2024 pm 01:24 PM

如何在jQuery中移除元素的height属性?在前端开发中,我们经常需要操作元素的样式属性。其中,height属性是一个常用的属性,用来控制元素的高度。在某些情况下,我们可能需要移除元素的height属性,让它恢复到原始状态或者让其根据内容自动撑开高度。在jQuery中,可以通过一些方法来移除元素的height属性。方法一:使用removeAttr()方法

See all articles

Outils d'IA chauds

Undresser.AI Undress

Undresser.AI Undress

Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover

AI Clothes Remover

Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool

Undress AI Tool

Images de déshabillage gratuites

Clothoff.io

Clothoff.io

Dissolvant de vêtements AI

AI Hentai Generator

AI Hentai Generator

Générez AI Hentai gratuitement.

Article chaud

R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
2 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌
Repo: Comment relancer ses coéquipiers
4 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: Comment obtenir des graines géantes
4 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌

Outils chauds

Navigateur d'examen sécurisé

Navigateur d'examen sécurisé

Safe Exam Browser est un environnement de navigation sécurisé permettant de passer des examens en ligne en toute sécurité. Ce logiciel transforme n'importe quel ordinateur en poste de travail sécurisé. Il contrôle l'accès à n'importe quel utilitaire et empêche les étudiants d'utiliser des ressources non autorisées.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) est une application Web PHP/MySQL très vulnérable. Ses principaux objectifs sont d'aider les professionnels de la sécurité à tester leurs compétences et leurs outils dans un environnement juridique, d'aider les développeurs Web à mieux comprendre le processus de sécurisation des applications Web et d'aider les enseignants/étudiants à enseigner/apprendre dans un environnement de classe. Application Web sécurité. L'objectif de DVWA est de mettre en pratique certaines des vulnérabilités Web les plus courantes via une interface simple et directe, avec différents degrés de difficulté. Veuillez noter que ce logiciel

SublimeText3 version anglaise

SublimeText3 version anglaise

Recommandé : version Win, prend en charge les invites de code !

Version crackée d'EditPlus en chinois

Version crackée d'EditPlus en chinois

Petite taille, coloration syntaxique, ne prend pas en charge la fonction d'invite de code

SublimeText3 Linux nouvelle version

SublimeText3 Linux nouvelle version

Dernière version de SublimeText3 Linux