首頁 >後端開發 >php教程 >[php] 二維碼

[php] 二維碼

WBOY
WBOY原創
2016-08-08 09:19:511121瀏覽

以ThinkPHP為例:

一、phpqrcode應用下載:http://sourceforge.net/projects/phpqrcode/files/應用程式下載:http://sourceforge.net/projects/phpqrcode/files/

應用程式下載:http://sourceforge.net/projects/phpqrcode/files/

應用程式下載: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教程有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn