use dosamigos\qrcode\QrCode; public function actionQrcode() { return QrCode::png('hello'); }
According to the original example, the picture cannot be displayed
use dosamigos\qrcode\QrCode; public function actionQrcode() { header('Content-Type: image/png'); ob_clean(); return QrCode::png('hello'); }
Find the problem and add this to solve it
Thank you everyone for the solutions
I haven’t used it, but you can check what the response header content-Type is and whether it is image/png
Use incorrectly! The parameter should be a url link---note that the link should be urldecoded$url = urldecode($url);QRcode::png($url);
use dosamigos\qrcode\QrCode; use yii\web\Response; public function actionQrcode() { \Yii::$app->response->format = Response::FORMAT_RAW; return QrCode::png('hello'); }
Find the problem and add this to solve it
Thank you everyone for the solutions
I haven’t used it, but you can check what the response header content-Type is and whether it is image/png
Use incorrectly!
The parameter should be a url link---note that the link should be urldecoded
$url = urldecode($url);
QRcode::png($url);