Google provides a generation of two-dimensional code interface, through the interface we can generate two-dimensional code, convenient and fast.
Interface address http://chart.apis.google.com/chart?chs= width high value x Width high value &cht=qr&chld= level | margin &chl= content
Parameter description:
Wide-high value: Generate two-dimensional code size, units are pixels, the current generated QR codes are square, so the two width and height values are set to the same value
Rating: Four levels, L Default: can identify lost 7% of the data, M can identify the loss of 15% of the data, Q can identify the loss of 25% of the data, H-can identify the loss of 30% of data
Margin: The distance from the picture border generated by the QR code
Content: Generate two-dimensional code content, but must be urlencode
<?php $data = isset ($_get[' t '])? $_get[' t ']: ' http://www.XXX.com '; $size = isset ($_get[' size ')? $_get[' size ': ' 150x150 '; $logo = isset ($_get[' logo ')? $_get[' logo ']: "./image/logo.jpg"; $chl = UrlEncode ($logo); $png = "http://chart.googleapis.com/chart?chs= $size &cht=qr&chl= $chl &chld=l|1&choe=utf-8"; $QR = Imagecreatefrompng ($png);//Outside that QR chart if ($logo!== FALSE) {$logo = Imagecreatefromstring (file_get_contents ($logo)); $ Qr_width = Imagesx ($QR); $QR _height = Imagesy ($QR); $logo _width = Imagesx ($logo); $logo _height = Imagesy ($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); } header (' Content-type:image/png '); Imagepng ($QR); Imagedestroy ($QR);;