Created
April 4, 2015 10:05
-
-
Save aamnah/9ad64398f2d58c345b74 to your computer and use it in GitHub Desktop.
Generate a QR code using Google Charts API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Source: http://stackoverflow.com/questions/5943368/dynamically-generating-a-qr-code-with-php | |
// Google Charts Documentation: https://developers.google.com/chart/infographics/docs/qr_codes?csw=1#overview | |
// CHart Type | |
$cht = "qr"; | |
// CHart Size | |
$chs = "300x300"; | |
// CHart Link | |
// the url-encoded string you want to change into a QR code | |
$chl = urlencode("http://aamnah.com"); | |
// CHart Output Encoding (optional) | |
// default: UTF-8 | |
$choe = "UTF-8"; | |
$qrcode = 'https://chart.googleapis.com/chart?cht=' . $cht . '&chs=' . $chs . '&chl=' . $chl . '&choe=' . $choe; | |
echo $qrcode . '<br>'; | |
?> | |
<img src="<?php echo $qrcode ?>" alt="My QR code"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment