php生成名片(vcard)二维码:
<?php
$vname = ‘test‘;
$vtel = ‘13800000000‘;
generateQRfromGoogle($vname,$vtel);
function generateQRfromGoogle($vname,$vtel,$widhtHeight =‘150‘,$EC_level=‘L‘,$margin=‘0‘)
{
if($vname&&$vtel){
$chl = "BEGIN:VCARD\nVERSION:3.0". //vcard头信息
"\nFN:$vname".
"\nTEL:$vtel".
"\nEND:VCARD"; //vcard尾信息
echo ‘<img src="http://chart.apis.google.com/chart?chs=‘.$widhtHeight.‘x‘.$widhtHeight.‘&cht=qr&chld=‘.$EC_level.‘|‘.$margin.‘&chl=‘.urlencode($chl).‘" alt="QR code" widhtHeight="‘.$size.‘" widhtHeight="‘.$size.‘"/>‘;
}
}
?>
php生成网址二维码:
<?php
$url = "http://www.google.com.hk";
generateQRfromGoogle($url);
function generateQRfromGoogle($chl,$widhtHeight =‘150‘,$EC_level=‘L‘,$margin=‘0‘)
{
echo ‘<img src="http://chart.apis.google.com/chart?chs=‘.$widhtHeight.‘x‘.$widhtHeight.‘&cht=qr&chld=‘.$EC_level.‘|‘.$margin.‘&chl=‘.urlencode($chl).‘" alt="QR code" widhtHeight="‘.$size.‘" widhtHeight="‘.$size.‘"/>‘;
}
?>
标签: php 二维码