search
HomePHP LibrariesOther librariesPHP QR code generation library
PHP QR code generation library

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

<?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 LibraryThe Ultimate PHP QR Code Library

15Jan2025

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 tutorialSummary of how to generate QR code with logo in php, summary of phplogo_PHP tutorial

12Jul2016

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

Automatic PHP Code Generation with MemioAutomatic PHP Code Generation with Memio

18Feb2025

This article explores the power of automated PHP code generation using the Memio library. Learn how to efficiently create PHP classes, methods, and properties, saving time and improving consistency. Key Advantages of Automated Code Generation with

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

13Dec2024

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 tutorialUse GD library to do verification code in php, phpgd library verification code_PHP tutorial

12Jul2016

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?

28Oct2024

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

See all articles