Home >Backend Development >PHP Tutorial >[php] QR code
Take ThinkPHP as an example:
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>
3. Use
<span><<span>img </span><span>src=</span><span>"__CONTROLLER__/qrcode" </span><span>alt=</span><span>"</span><span宋体'">百度一下二维码</span><span>"</span>/></span>
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.