The content of this article is about converting PHP URLs to generate QR codes. It has certain reference value. Now I share it with you. Friends in need can refer to it.
1. Use the PHP class library PHP QR Code; official website download: http://phpqrcode.sourceforge.net
2. Download and unzip, then copy (or copy) the phpqrcode folder to the project;
3. Then call this class in the controller to generate the QR code
public function erweima(){ $id=I('get.phone'); vendor("phpqrcode.phpqrcode"); $code = new \QRcode(); // include ( APP_PATH . 'Home/Conf/phpqrcode/phpqrcode.php' );//定义纠错级别 $errorLevel = "L";//定义生成图片宽度和高度;默认为3 $size = "4";//定义生成内容 $content='http://' . I( 'server.HTTP_HOST' ) . U( 'Login/register' ) . '?phone='.$id; //调用QRcode类的静态方法png生成二维码图片// $code->png($content, false, $errorLevel, $size);//生成网址类型 $url="http://jingyan.baidu.com/article/48a42057bff0d2a925250464.html"; $url.="rn"; $url.="http://jingyan.baidu.com/article/acf728fd22fae8f8e510a3d6.html"; $url.="rn"; $url.="http://jingyan.baidu.com/article/92255446953d53851648f412.html"; print_r($code->png($url, false, $errorLevel, $size)); }
Related recommendations:
php Convert seconds to duration (h:i:s format)
The above is the detailed content of Convert php URL to generate QR code. For more information, please follow other related articles on the PHP Chinese website!