我正在尝试将某些数据转换为网页上的QR。要做到这一点,我使用'php qrcode'。
Sourceforge图书馆主页:http://phpqrcode.sourceforge.net/
我无法使用该库生成QR码。我错过了PHP扩展。
以为我错过了GD2扩展,我做了:
brew install gd
当前代码:
include( '../phpqrcode/qrlib.php' );
QRcode::png( 'PHP QR Code : )' );
当前输出:
PNGIHDRWWKK/PLTE U ~ IDAT8 ұ ұPG. N t t,V H,pe 4Ĵq k j “^ lphSn8D> 3T - %:\ Z4 {OL C-_O rrmx +,}ö|iʚt{oZ6 \,I {5몏{Ϫ/ MIENDB `
编辑: 我试过将html标题更改为image / png。相同的结果。
<meta http-equiv="content-type" content="image/png" charset="UTF-8">
编辑:完整的示例代码,相同的结果,没有QR码。
<?php header('Content-type: image/png'); ?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta http-equiv="content-type" content="image/png" charset="utf-8">
<title></title>
</head>
<body>
<?php
include( '../phpqrcode/qrlib.php' );
QRcode::png( 'PHP QR Code : )' );
?>
</body>
</html>
编辑:以下显示相同的结果
<?php
header('Content-type: image/png');
include( '../phpqrcode/qrlib.php' );
QRcode::png( 'PHP QR Code : )' );
?>
编辑: 使用laravel框架