Home PHP Libraries Other libraries PHP QR code generation library
PHP QR code generation library
<?php   
    class QRbitstream {
    
        public $data = array();
        
        //----------------------------------------------------------------------
        public function size()
        {
            return count($this->data);
        }
        
        //----------------------------------------------------------------------
        public function allocate($setLength)
        {
            $this->data = array_fill(0, $setLength, 0);
            return 0;
        }
    
        //----------------------------------------------------------------------
        public static function newFromNum($bits, $num)
        {
            $bstream = new QRbitstream();
            $bstream->allocate($bits);
            
            $mask = 1 << ($bits - 1);
            for($i=0; $i<$bits; $i++) {
                if($num & $mask) {
                    $bstream->data[$i] = 1;
                } else {
                    $bstream->data[$i] = 0;
                }
                $mask = $mask >> 1;
            }
            return $bstream;
        }

This QR code generation library is very easy to use. Of course, your PHP environment must enable GD2 support. This library provides a key png() method, in which the parameter $text indicates the generation of two-digit information text; the parameter $outfile indicates whether to output a QR code image file, the default is no; the parameter $level indicates the fault tolerance rate, that is, there is The covered areas can also be identified, which are L (QR_ECLEVEL_L, 7%), M (QR_ECLEVEL_M, 15%), Q (QR_ECLEVEL_Q, 25%), H (QR_ECLEVEL_H, 30%); the parameter $size indicates the size of the generated image, The default is 3; the parameter $margin indicates the spacing value of the blank area of ​​the border around the QR code; the parameter $saveandprint indicates whether to save the QR code and display it.

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP QR Code barcode and QR code generation class library PHP QR Code barcode and QR code generation class library

25 Jul 2016

PHP QR Code barcode and QR code generation class library

HP QR Code is a PHP QR code generation library HP QR Code is a PHP QR code generation library

29 Jul 2016

:This article mainly introduces HP QR Code, a PHP QR code generation library. Students who are interested in PHP tutorials can refer to it.

Implement WeChat QR code generation in PHP Implement WeChat QR code generation in PHP

13 May 2023

With the development and popularization of mobile Internet, WeChat has become an indispensable part of people's life and work. In order to meet the needs of users, WeChat continues to launch new functions, the most important of which is WeChat payment. In order to use WeChat payment, you must have a reliable QR code generation function. This article will introduce how to generate WeChat QR code in PHP. First of all, we need to make it clear that there are two ways to generate WeChat QR codes, one is a permanent QR code and the other is a temporary QR code. The permanent QR code is only available when the user

PHP QR code generation code PHP QR code generation code

25 Jul 2016

PHP QR code generation code

php QR code generation php QR code generation

08 Aug 2016

:This article mainly introduces PHP QR code generation. Students who are interested in PHP tutorials can refer to it.

php QR code generation php QR code generation

03 Sep 2019

It is quite difficult to generate QR codes using PHP language. You can use phpqrcode, a ready-made class file and PHP QR code generation class library, to easily generate QR codes.

See all articles