http://sourceforge.net/projects/phpqrcode/,是一个很棒的库,但我找不到如何将png图像作为字符串返回,基本的例子是
QRcode::png('code data text', 'filename.png'); // creates file
QRcode::png('some othertext 1234'); // creates code image and outputs it directly into browser
Run Code Online (Sandbox Code Playgroud)
我检查了文档,没有,帮助!:乙
Lus*_*ian 19
ob_start();
QRCode::png('text', null);
$imageString = base64_encode( ob_get_contents() );
ob_end_clean();
Run Code Online (Sandbox Code Playgroud)
$qrTempDir = 'path/to/your/temp';
$filePath = $qrTempDir.'/'.uniqid();
QRcode::png('some text', $filePath);
$qrImage = file_get_contents($filePath);
unlink($filePath);
Run Code Online (Sandbox Code Playgroud)
这应该是您要寻找的。您可以扩展它以显示如下图像:
<img src="data:image/png;base64,<?php echo base64_encode($qrImage) ?>" />
Run Code Online (Sandbox Code Playgroud)
不幸的是,该库目前不支持任何其他方法,因为在没有file参数的情况下调用QRcode :: png函数不仅使它发送了这些标头,而且还退出了代码执行,因此不会撤消或覆盖标头。
| 归档时间: |
|
| 查看次数: |
8745 次 |
| 最近记录: |