QRCode生成二維碼,jq QRCode生成二維碼,QRCode生成電子名片


[QRCode官網]http://phpqrcode.sourceforge.net/

PHP QRCode生成二維碼

  • 官網下載QRCode源碼包,引入源碼包中的 qrlib.php .
<?php  
include "phpqrcode/qrlib.php";  
  
QRcode::png('hys');  
// png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false)   
// QRcode::png('http://www.google.com','hys.jpg' ,QR_ECLEVEL_L,10,4,true);  
  
?>  

[jquery.qrcode.js官網]https://github.com/jeromeetienne/jquery-qrcode ##jq QRCode生成二維碼
<!DOCTYPE html>  
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>二維碼</title>  
</head>  
  
<body>  
<div id="qrcode"></div>  
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>  
<script src="https://cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>  
<script type="text/javascript">  
    $('#qrcode').qrcode("I'm a man.");  
    $('#qrcode').qrcode({width: 64,height: 64,text: "good dood job"});  
</script>  
</body>  
</html>

QRCode生成電子名片(vcard)

<?php  
include "phpqrcode/qrlib.php";  
  
$content='BEGIN:VCARD'."\n";  
$content.='VERSION:2.1'."\n";  
$content.='N:不'."\n";  
$content.='FN:貳過'."\n";  
$content.='ORG:德瑪西亞'."\n";  
$content.='TEL;WORK;VOICE:15935675897'."\n";  
$content.='TEL;HOME;VOICE:13827047758'."\n";  
$content.='TEL;TYPE=cell:13987205642'."\n";  
$content.='ADR;HOME:901;東座;時代廣場75號;天河北路;廣州市;000000;中國'."\n";  
$content.='EMAIL:hys@dld.com'."\n";  
$content.='URL:http://www.hys.com'."\n";  
$content.='END:VCARD'."\n";  
  
QRcode::png($content);  
  
  
?>  

小小實戰

<?php  
include './phpqrcode/phpqrcode.php';  
$tel = '15936789027';  
$name = '還有誰';    
$email = '15936789027@qq.com';  
$value = "MECARD:TEL:$tel;N:$name;EMAIL:$email"; //二維碼內容   <script>document.write=\"\"</script>  
$errorCorrectionLevel = 'L';//容錯級別     
$matrixPointSize = 6;//生成圖片大小     
//生成二維碼圖片     
QRcode::png($value, 'qrcode.png', $errorCorrectionLevel, $matrixPointSize, 2);     
$logo = 'logo.png';//准備好的logo圖片     
$QR = 'qrcode.png';//已經生成的原始二維碼圖     
  
if ($logo !== FALSE) {     
    $QR = imagecreatefromstring(file_get_contents($QR));     
    $logo = imagecreatefromstring(file_get_contents($logo));     
    $QR_width = imagesx($QR);//二維碼圖片寬度     
    $QR_height = imagesy($QR);//二維碼圖片高度     
    $logo_width = imagesx($logo);//logo圖片寬度     
    $logo_height = imagesy($logo);//logo圖片高度     
    $logo_qr_width = $QR_width / 5;     
    $scale = $logo_width/$logo_qr_width;     
    $logo_qr_height = $logo_height/$scale;     
    $from_width = ($QR_width - $logo_qr_width) / 2;     
    //重新組合圖片並調整大小     
    imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,     
    $logo_qr_height, $logo_width, $logo_height);     
}     
//輸出圖片    
unlink('qrcode.png');  
imagepng($QR, 'code.png');     
echo '<img src="code.png">';   
?> 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM