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

The Ultimate PHP QR Code Library The Ultimate PHP QR Code Library

15 Jan 2025

HeroQR: Your dream PHP QR code generation library. Are you still worried about QR code generation in PHP? Don't hesitate any longer! ?I am pleased to introduce you to HeroQR, an advanced open source PHP library designed to make QR code generation easy, powerful and flexible. Why choose HeroQR? HeroQR stands out for its customizability and ease of use. Whether you're a beginner looking for a simple QR code solution or an experienced developer in need of advanced features, HeroQR has what you need. Main Features of HeroQR HeroQR is designed to provide developers with powerful tools to create and customize QR codes. Here’s a quick overview of its standout features: Unparalleled customization with resizable additions

Summary of how to generate QR code with logo in php, summary of phplogo_PHP tutorial Summary of how to generate QR code with logo in php, summary of phplogo_PHP tutorial

12 Jul 2016

Summary of the method of generating QR code with logo in php, summary of phplogo. Summary of the method of generating QR code with logo in php, summary of phplogo 1. Class libraries used 1. phpqrcode (php library) 2. qrcode.js (javascript library) 2. Use of phpqrcode Only use php class library, also

How Do I Link Static Libraries That Depend on Other Static Libraries? How Do I Link Static Libraries That Depend on Other Static Libraries?

13 Dec 2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

Use GD library to do verification code in php, phpgd library verification code_PHP tutorial Use GD library to do verification code in php, phpgd library verification code_PHP tutorial

12 Jul 2016

In php, GD library is used for verification code, and phpgd library is used for verification code. Use GD library to do verification code in php, phpgd library verification code php require_once 'string.func.php';//Use GD library to do verification code/** *Add verification text* @param int $type * @param int $length */function

How to Silence TensorFlow\'s Debugging Output? How to Silence TensorFlow\'s Debugging Output?

28 Oct 2024

Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...

How Does jQuery Simplify DOM Manipulation for Web Developers? How Does jQuery Simplify DOM Manipulation for Web Developers?

03 Jan 2025

Overflow: Hidden and Expansion of HeightjQuery distinguishes itself from other JavaScript libraries through its cross-platform compatibility and...

See all articles