简体   繁体   English

php二维码 - 显示文本而不是图像

[英]php QR code - Shows text instead of image

I'm trying to get a QR code working. 我正在努力让QR码正常工作。

when i run it like: 当我运行它像:

<?php
include 'phpqrcode/qrlib.php';

QRcode::png('hwllo');
?>

it's working. 它正在工作。 However if i run it with some other php code 但是如果我用其他一些PHP代码运行它

<?php
include 'phpqrcode/qrlib.php';

echo 'Hello world';

QRcode::png('hwllo');
?>

it displays: 它显示:

Hello world‰PNG IHDRWWKK/PLTEÿÿÿUÂÓ~²IDAT8ÍÒ1„ Ðo(èô&^ƒŽ+0r¸× ávÆYbÖÝ-phêM÷ùð´ˆLHD'qá‚XÁZ'ç“Ë › š¶H CX™¾ª.ùú½¥êsUT<±eqhÖy|áÓÃ;š¶¼wž3d„D8÷ŠÈ—*ÀøÌEEÆgãL \\ú4a_ÀZ§UŠãúw¶35l|ìër_Lë•¡ê'ßQœçgÍü#Ãò¡IEND®B Hello world‰PNG IHDRWWKK /PLTEÿÿÿUÂÓ~²IDAT8ÍÒ1“Ðo(èô&^ƒŽ+0r¸×ávÆYbÖÝ-phêM÷ùð'LHD'qá,XÁZ'ç”Ë>š¶HCX™¾ª.ùú½¥êsUT<±eqhÖy|áÓà ;š¶¼wž3d“D8÷ŠÈ-*ÀøÌEEÆgãL \\ú4a_ÀZ§UŠãúw¶35l|ìër_Lë•¡ê'ßQœçgÍü#Ãò¡IEND®B

You can't put text like that inside an image, it will make it malformed/corrupted and not display. 你不能在图像中放置这样的文本,它会使它变形/损坏而不显示。 Use your previous code and do no echo anything out inside the image. 使用您之前的代码,不要在图像中回显任何内容。 If you need to put text next to the image use HTML and link to the QR image file using an IMG tag as you would a normal image file for an HTML page. 如果您需要在图像旁边放置文本,请使用HTML并使用IMG标记链接到QR图像文件,就像使用HTML页面的普通图像文件一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM