PHP 生成二维码

jquery版

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{margin:0;padding:0}
        .absoluteCenter{ width:250px; height:250px;position:absolute; text-align: center; left:50%; top:50%; margin-left: -150px; margin-top: -150px;  }
    </style>
</head>
<body>
    <div id="code" class="absoluteCenter">
        <p style="margin-bottom: 30px; margin-top: -30px;">Share with friends</p>
    </div>
</body>
</html>

<!--<script type="text/javascript" src="jquery.js"></script>-->
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="/template/default/code-css/jquery.qrcode.min.js"></script>
<script>
    $("#code").qrcode({
        render: "table", //table方式
        width: 250, //宽度
        height:250, //高度
        text: "Remember to share with friends oh 😊:" //任意内容
    });
</script>
//控制器生成

//安装
$ composer require endroid/qrcode
<?php use Endroid\QrCode\QrCode; $qrCode = new QrCode(); $qrCode->setText('Life is too short to be generating QR codes') ->setSize(300) ->setPadding(10) ->setErrorCorrection('high') ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0)) ->setBackgroundColor(array('r'=>255,'g'=>255,'b'=>255,'a'=>0)) ->setLabel('Scan the code') ->setLabelFontSize(16) ->setImageType(QrCode::IMAGE_TYPE_PNG); // now we can directly output the qrcode header('Content-Type: '.$qrCode->getContentType()); $qrCode->render();

posted @ 2020-04-06 00:59  祈愿仙帝  阅读(217)  评论(0编辑  收藏  举报