namespace app\home\controller;
use think\Controller;
class Qcode extends Controller {
/**
* 生成二维码
*/
public function index() {
import('pay.weixin.example.phpqrcode.phpqrcode', EXTEND_PATH);
$url = urldecode($_GET["data"]);
ob_end_clean();//清空(擦除)缓冲区并关闭输出缓冲
if(substr($url, 0, 6) == "weixin"){
\QRcode::png($url);
}else{
header('HTTP/1.1 404 Not Found');
}
}
}
之前一直不能生成二维码,清空缓冲区就可以了
ob_end_clean();//清空(擦除)缓冲区并关闭输出缓冲