ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
1.安装 composer require endroid/qr-code 2.使用 ``` use Endroid\\QrCode\\QrCode; public function qr_code{ $qrCode = new QrCode('http://baidu.com'); $name = rand(1,99999999).time(); $path ='static/qrcode/'.$name.'.png'; $qrCode->writeFile($path); header('Content-Type: '.$qrCode->getContentType()); echo $qrCode->writeString(); //@去操作这张图片 //@删除文件 unlink($path); exit; } ``` ``` 加logo public function qr_logo(){ $set_log =true; $qrCode = new QrCode('http://baidu.com'); if($set_log ==true){ $qrCode->setLogoPath('thumb/link.jpg'); $qrCode->setLogoWidth(90); } $qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH); $name = rand(1,99999999).time(); $path ='static/qrcode/'.$name.'.png'; $qrCode->writeFile($path); header('Content-Type: '.$qrCode->getContentType()); echo $qrCode->writeString(); unlink($path); } } ``` 3.简单配置 ``` $qrCode = new QrCode('https://www.baidu.com/'); $qrCode->setSize(150); $qrCode->setMargin(10); $qrCode->setLogoPath(__DIR__ . '/logo.png'); $qrCode->setLogoSize(40, 40); header('Content-Type: ' . $qrCode->getContentType()); echo $qrCode->writeString(); ``` 4.其他 https://www.jianshu.com/p/9b933907acd6