[php] QR code

WBOY
Release: 2016-08-08 09:19:51
Original
1113 people have browsed it

Take ThinkPHP as an example:

1. phpqrcodeapplication download: http://sourceforge.net/projects/phpqrcode/files/

Import the download package into the third-party application directory, or It is under the Vendor directory

2. How to generate QR code:

<span><span>/* </span><span>二维码</span><span> */
</span><span>public function </span><span>qrcode</span>(<span><em>$url</em></span><span>=</span><span>'http://www.baidu.com'</span>,<span><em>$level</em></span><span>=</span><span>3</span>,<span><em>$size</em></span><span>=</span><span>4</span>){
    <span>Vendor</span>(<span>'phpqrcode.phpqrcode'</span>);
    $errorCorrectionLevel <span>=</span><span><em>intval</em></span>(<span><em>$level</em></span>) ;<span>//</span><span>容错级别
</span><span></span>$matrixPointSize <span>= </span><span><em>intval</em></span>(<span><em>$size</em></span>);<span>//</span><span>生成图片大小
</span><span></span><span>//</span><span>生成二维码图片</span><span></span><span></span>$object <span>= new </span>\QRcode();
    $object<span>-></span><span>png</span>(<span><em>$url</em></span>, <span>false</span>, $errorCorrectionLevel, $matrixPointSize, <span>2</span>);
}</span>
Copy after login

3. Use

<span><<span>img </span><span>src=</span><span>"__CONTROLLER__/qrcode" </span><span>alt=</span><span>"</span><span宋体'">百度一下二维码</span><span>"</span>/></span>
Copy after login

in the template Thank you for your attention!

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces the [php] QR code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template