Directly look at the code. This is the code in thinkphp to generate a QR code {code ...} this is the code & amp; lt; body & amp; gt; & amp; lt; divclass & quot; img & quot; & amp; gt; & amp; lt; imgalt & quot; QR code & quot; src & quot; index. phpRecrecommend & quot; & amp; gt; & amp; lt; div & amp; gt; & amp; lt; body & amp; gt...
View Code directly
This is the QR code generated by the code in thinkphp.
$ Model = M ("member"); $ rs = $ model-> where ("tmId ". $ tmId)-> find (); // generate the QR code vendor ("phpqrcode. phpqrcode "); $ path = 'public/qrcode/'; mkdir ($ path); then qr?#path.'qrcode.png'; $ text =" http://www.xghm.com.cn/index.php/Login/reg/tmTel ". $ rs ['tmtel']; $ size = '4'; $ level = 'l'; $ padding = 2; $ logo = false; QRcode: png ($ text, $ QR, $ level, $ size, $ padding); $ this-> display ();
This is the code in the template.
However, the output result is as follows:
Where is the problem ??
Reply content:
View Code directly
This is the QR code generated by the code in thinkphp.
$ Model = M ("member"); $ rs = $ model-> where ("tmId ". $ tmId)-> find (); // generate the QR code vendor ("phpqrcode. phpqrcode "); $ path = 'public/qrcode/'; mkdir ($ path); then qr?#path.'qrcode.png'; $ text =" http://www.xghm.com.cn/index.php/Login/reg/tmTel ". $ rs ['tmtel']; $ size = '4'; $ level = 'l'; $ padding = 2; $ logo = false; QRcode: png ($ text, $ QR, $ level, $ size, $ padding); $ this-> display ();
This is the code in the template.
However, the output result is as follows:
Where is the problem ??
Remove the last $ this-> display ();. It is best to add ob_clean () before generating the image ()
I have a similar method in my code.
public function qrcode($guid) { vendor("phpqrcode.phpqrcode"); //$data = "http://www.baidu.com"; $url="http://".$_SERVER['HTTP_HOST'].U('Urlhandle/show',array('guid'=>$guid),$domin=true); $level = 'L'; $size = 8; ob_clean(); \QRcode::png($url,false,$level,$size); }
Effect you can go to http://www.wx2share.com to see
We recommend that you use the phpqrcode plug-in to generate a QR code.
public function qrcode($text='https://www.baidu.com',$level=3,$size=4){ $text=$this->$_get['text']?$this->$_get['text']:$text; $size=$this->$_get['size']?$this->$_get['size']:$size; $level=$this->$_get['level']?$this->$_get['level']:$level; Vendor('phpqrcode.phpqrcode'); $object = new \QRcode(); $object->png($text, false, $level, $size, 2);}
The Landlord seems to be confused.
The first is the QR code, which requires an independent action.
Display interface, which is another action
For example:
Public function action1 () {$ this-> display ();} public function action2 (){............ QRcode: png ($ text, $ QR, $ level, $ size, $ padding);} in the template:
Then access action1.
Generate a separate method and use src of the img label to access this method,