PHP generates two-dimensional code card

Source: Internet
Author: User
Tags vcard
[PHP] Code
  1. /*
  2. * PHP generates two-dimensional code card
  3. * API Google
  4. * Google API QR code generation "QRCode can store up to 4,296 alphanumeric types of arbitrary text, you can view the QR code data format"
  5. * @param string $chl QR code contains information, which can be numeric, character, binary information, Chinese characters. Data types cannot be mixed, and data must be UTF-8 url-encoded. If you need to pass more than 2K bytes of information, use the Post method
  6. * @param int $widhtHeight size setting for two-dimensional code generation
  7. * @param string $EC _level Optional error correction level, QR code supports four levels of error correction, used to recover lost, misread, blurred, data.
  8. * L-Default: Can identify lost 7% of the data
  9. * M-can identify data that has lost 15%
  10. * Q can identify data that has lost 25%
  11. * H can identify data that has lost 30%
  12. * @param int $margin The distance from the picture border generated by the two-dimensional code
  13. * Two-dimensional Code card format---vcard
  14. * Format reference is as follows:
  15. Begin:vcard
  16. version:3.0
  17. FN: User Name
  18. TEL; CELL; voice:15201280000
  19. TEL; work; voice:010-62100000
  20. TEL; work; fax:010-62100001
  21. EMAIL; Pref;internet:lzw#lzw.me
  22. Url:http://lzw.me
  23. OrG: Chi-Wen Studio
  24. ROLE: Product Division
  25. Title:cto
  26. ADR; work; POSTAL: No. 35th North Four Ring road, Chaoyang District, Beijing 100101
  27. rev:2012-12-27t08:30:02z
  28. End:vcard
  29. If you want to customize the format in more detail, you need to know the format standard of the vcard in detail.
  30. */
  31. $vcard = Array (
  32. ' VName ' = ' user name ',
  33. ' Vtel ' = ' 13700000000 ',
  34. ' Vemail ' = ' playby@163.com ',
  35. ' Vaddress ' and ' Chaoyang District, Beijing ',
  36. );
  37. Generateqrfromgoogle ($vcard);
  38. function Generateqrfromgoogle ($vcard, $widhtHeight = ' Max ', $EC _level= ' L ', $margin = ' 0 ')
  39. {
  40. if ($vcard) {
  41. $chl = "begin:vcard\nversion:3.0". vcard Header information
  42. "\NFN: '". $vcard [' VName '].
  43. "\ntel:". $vcard [' Vtel '].
  44. "\nemail:". $vcard [' Vemail '].
  45. "\nadr:". $vcard [' vaddress '].
  46. "\nend:vcard"; vcard Tail Information
  47. Echo ';
  48. }
  49. }
  50. ?>
Copy Code
Php
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.