【问题标题】:generate qrcode with base64 php html使用base64 php html生成二维码
【发布时间】:2021-12-04 17:59:19
【问题描述】:

所以我有这个 PHP 代码可以在 WordPress 中生成 QR 码,但是一些税务角色要求代码使用 base64,所以我想让我的代码使用 Hexadecimal Encode 64 和 utf8 有什么帮助吗? 我的代码

<?php
        $barcodetype = (get_option('plugindistrict_orderbarcodes_barcodetype') == '' ? 'qrcode' : get_option('plugindistrict_orderbarcodes_barcodetype'));

?>
        <div class="pd_order_barcode_div" style="text-align: right; margin: 40px; ">
         
                 <img class="pd_order_barcode" style="margin-top: -155; margin-right: 50; width:20%  " src="https://2tfh7u96zl.execute-api.us-east-1.amazonaws.com/added-jest-tests/barcode?type=<?php echo $barcodetype.'&value='.(($barcodetype == 'qrcode') ? $checkinpath .'Name:Sleep Blue'.'%0A'.'Tax No:302188012300003'.'%0A'.'Bill NO:'.$this->get_formatted_number().'%0A'.'Date-Time:'.$this->get_formatted_date().'%0A'.'Bill Amt With Vat:'.$order->get_total().'%0A'.'Vat Amt:'.$order->get_total_tax(): $order).'&includeText='.(get_option('plugindistrict_orderbarcodes_showtextupc') == 1 ? 'true' : 'false'); ?>" />

``

【问题讨论】:

  • 您尝试过什么让它发挥作用?究竟是什么没有按预期工作?
  • 我想让代码用base64生成二维码,PHP代码没有问题只是想添加一些行使其生成base64
  • 请通过编辑为您的问题添加所有说明。如果一切正常,您的问题是什么?
  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: php html wordpress


【解决方案1】:

生成动态二维码并显示的最佳方式。 你可以使用不需要转换成base64/保存文件的google API。

要使用这个,基本上:

https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8

300x300是你要生成的二维码图片的大小, chl 是您要更改为二维码的 url 编码字符串,并且 choe 是(可选)编码。 上面的链接提供了更多详细信息,但要使用它,只需将图像的 src 指向操作值,如下所示:

<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8" title="Link to Google.com" />

结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    • 2014-08-14
    • 1970-01-01
    相关资源
    最近更新 更多