//laravel
Public functionindex () {$urlToEncode= "Http://www.baidu.com"; $this-Generateqrfromgoogle ($urlToEncode); //return view (' Welcame '); } Public functionGenerateqrfromgoogle ($chl,$widhtHeight= ' 150 ',$EC _level= ' L ',$margin= ' 0 ') { $chl=UrlEncode($chl); Echo' $widhtHeight.‘ X '.$widhtHeight.‘ &cht=qr&chld= '.$EC _level. ' | '.$margin.‘ &choe=utf-8&chl= '.$chl. ' "alt=" QR Code "widhtheight=".$widhtHeight.‘"widhtheight="‘.$widhtHeight.‘" /> '; }
//php
$urlToEncode= "Http://www.jb51.net"; Generateqrfromgoogle ($urlToEncode); /** * 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" * @param string $chl QR Code contains information, can be numbers, characters, binary information, Chinese characters. Data types cannot be mixed, data must go through UTF-8 url-encoded * @param int $widhtHeight dimension setting for QR code * @param string $EC _level Optional error correction level, QR code supports four levels of error correction to recover lost Missing, misread, fuzzy, data. * L-Default: can identify loss of 7% of data * M can identify loss of 15% of data * Q can identify lost 25% of the data * H can recognize the loss of 30% data * @param int $margin The resulting QR code distance from the picture border*/functionGenerateqrfromgoogle ($chl,$widhtHeight= ' 150 ',$EC _level= ' L ',$margin= ' 0 ') { $chl=UrlEncode($chl); Echo' $widhtHeight.‘ X '.$widhtHeight.‘ &cht=qr&chld= '.$EC _level. ' | '.$margin.‘ &choe=utf-8&chl= '.$chl. ' "alt=" QR Code "widhtheight=".$widhtHeight.‘"widhtheight="‘.$widhtHeight.‘" /> ';}
Quickly generate QR codes with Google API