1. Home
  2. /
  3. Web technology
  4. /
  5. PHP
  6. /
  7. [ PHP ] –...

[ PHP ] – 產生QR-Code

評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]

1.請先到該網站下載檔案
http://www.swetake.com/qrcode/qr_cgi_e.html
2.將下載的檔案上傳到你的主機上
3.閱讀 readme
http://www.swetake.com/qrcode/README-e.txt
4.參數
qr_img.php?d=data[&e=(L,M,Q,H)][&s=int size][&v=(1-40)][&t=J]
[&m=(1-16)&n=(2-16)[&o=original data][&p=(0-255)]]
d : Data you want to encode to QRcode.
A special letter like ‘%’.space or 8bit letter must be URL-encoded.
You cannot omit this parameter.
e : Error correct level
You can set ‘L’,’M’,’Q’ or ‘H’.
If you don’t set,program selects ‘M’.
s : module size
This parameter is no effect in HTML mode.
You can set a number more than 1.
Image size depends on this parameter.
If you don’t set,program selects ‘4’ in PNG mode or ‘8’ in JPEG mode.
v : version
You can set 1-40.
If you don’t set,program automatically selects.
t : image type
You can set ‘J’,’H’ or other.
‘J’ : jpeg mode.
‘H’ : html mode.(for perl only)
Other : png mode.
If you don’t set,program select PNG mode.
修改 qr_img.php 最下方程式
[php]
<?php
/*
#— output image
#
*/
Header("Content-type: image/".$qrcode_image_type);
ImageCopyResized($output_image,$base_image,0,0,0,0,$qrcode_image_size,$qrcode_image_size,$mib,$mib);
if ($qrcode_image_type == "jpeg"){
//原本程式 ImageJpeg($output_image);
ImageJpeg($output_image,’./img/’.$qrcode_data_string.’.jpg’);//改這樣才能存檔
} else {
//原本程式 ImagePng($output_image);
ImagePng($output_image,’./img/’.$qrcode_data_string.’.png’);//改這樣才能存檔
//記得img這個資料夾的權限要開成777
}
?>
[/php]

評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]
!去下營經續永站本助幫能就下一點輕輕,話的您到助幫有章文的我果如 如果我的文章有幫助到您的話,輕輕點一下就能幫助本站永續經營下去!

2 thoughts on “[ PHP ] – 產生QR-Code

    1. 你給d 的參數中有特殊字元 所以要先用 PHP urlencode 編碼過才可以
      urlencode(‘http://localhost/a.php?a=1&b=2&c=3’);
      & 字符在$_GET中是切割參數的依據所以你的網址如果沒有先編碼過就會只顯示到 &前面的資料

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *