以ThinkPHP為例:
應用程式下載:http://sourceforge.net/projects/phpqrcode/files/是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><<span>img </span><span>src=</span><span>"__CONTROLLER__/qrcode" </span><span>alt=</span><span>"</span><span宋体'">百度一下二维码</span><span>"</span>/></span>
謝謝關注!
版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。
以上就介紹了[php] 二維碼,包含了方面的內容,希望對PHP教程有興趣的朋友有幫助。