共计 470 个字符,预计需要花费 2 分钟才能阅读完成。
安装依赖包
在 composer.json
文件添加..
{
"require": {
"php": "^7.2",
"chillerlan/php-qrcode": "dev-master"
}
}
执行安装
composer install --no-dev
示例代码
以下是在 phalcon
框架中的使用
...
public function qrcodeAction() {$qrcodeContent = $this->request->get('content');
$options = new QROptions(['version' => QRCode::VERSION_AUTO,
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
'eccLevel' => QRCode::ECC_L,
'scale' => 6,
'imageBase64' => false,
]);
$this->response->setContentType("image/png");
return (new QRCode($options))->render($qrcodeContent);
}
...
正文完