您好,欢迎访问一九零五行业门户网

php qrcode 输出乱码怎么解决

php qrcode输出乱码的解决方法:首先打开相应的php文件;然后找到执行生成二维码的代码部分;最后在该代码后面添加“die;”或“exit;”即可。
本文操作环境:windows7 系统、php7.1版,dell g3电脑
php qrcode 输出乱码怎么解决?
解决phpqrcode.php生成二维码输出到页面上出现乱码问题
先来看一下乱码:
 解决方法:在执行生成二维码的那句代码之后添加die;或exit;即可。如果还是不行,可以用编程工具把.php文件转为“utf-8 无bom编码格式”
<?phpnamespace app\index\controller;use think\cache;use think\controller;use think\db;use think\session;use think\request;/**引入类库方式一(extend/phpqrcode.php)*/import('phpqrcode', extend_path);/* *二维码生成api接口(对外) */class qr extends jcb{ public function api(){ if(!isset($_get['text'])){ header("content-type: text/html; charset=utf-8"); echo '参数错误.'; exit; } $text = strtoupper(trim($_get['text'])); //访问频率 if(cache::get($text)){ header("content-type: text/html; charset=utf-8"); echo '请求频率太快,5秒内仅允许一次刷新';exit; }else{ cache::set($text,'1',$this->config['visit-interval']); } //引入类库方式二(在vendor下创建phpqrcode目录,并且把phpqrcode.php文件放进去) //vendor('phpqrcode.phpqrcode'); $errorcorrectionlevel =intval(2) ;//容错级别 $matrixpointsize = intval(4); //生成图片大小 $margin =1; //外边距离(白边) //方式一 \qrcode::png($text,false, $errorcorrectionlevel, $matrixpointsize, 1); //方式二 //$qr = new \qrcode(); //$qr->png($text,false, $errorcorrectionlevel, $matrixpointsize, 1); die; }}
最终效果图:
推荐学习:《php视频教程》
以上就是php qrcode 输出乱码怎么解决的详细内容。
其它类似信息

推荐信息