使用phpqrcode库添加url

时间:2013-10-02 17:48:17

标签: php url qr-code

我想创建一个包含网址的QR码。
例如:

Product Details :
Name : XYZ
Price : $43
Url : www.abc.com/rty
Description : Wonderful product

我设法显示这些数据,但不是那种确切的格式。在解码时输出(下面):

Product Details : \n    Name : XYZ \n    Id : 43 \n    Link : www.abc.com/rty \n     Description : Wonderful product 

请帮忙。

使用Phpqrcode库。

我的代码:

    $contents = $producttype.'\n';
    $contents .= 'Name : '.$collection->getName().'\n';
    $contents .= 'Id : '.$collection->getId().'\n';
    $contents .= 'Link :'.Mage::getUrl().$collection->getUrlKey().'\n';
    $contents .= 'Description : '.$collection->getShortDescription().'\n';

    $imagename = 'qrcode' . md5($collection->getId()) . '.png';
    $filename = $PNG_TEMP_DIR.$imagename;

    QRcode::png($contents, $filename, $errorCorrectionLevel, $matrixPointSize, 2);

数据变得动态,人们可以很容易地假设。

1 个答案:

答案 0 :(得分:1)

好的做完了。
对于第二行的数据,使用了PHP_EOL

QRcode::png("http://www.abc.com", "test.png", "L", 4, 4);

但是,如果我只添加上面的代码,那么它会提供 url type qrcode
此外,链接部分还取决于用于读取QR码的应用程序。