以ThinkPHP为例:
把下载包导入到三方应用目录下,也就是Vendor目录下
二、生成二维码的方法:
<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>
三、在模板中使用
<span>img </span><span>src=</span><span>"__CONTROLLER__/qrcode" </span><span>alt=</span><span>"</span><span>百度一下二维码</span><span>"</span>/>
谢谢关注!
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了[php] 二维码,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。