Skip to content

Instantly share code, notes, and snippets.

@rezarajan
Forked from aamnah/google_api_qrcode.php
Created June 19, 2017 20:39
Show Gist options
  • Select an option

  • Save rezarajan/66ed58c18f2c2bb51ed0e42dd4437738 to your computer and use it in GitHub Desktop.

Select an option

Save rezarajan/66ed58c18f2c2bb51ed0e42dd4437738 to your computer and use it in GitHub Desktop.
Generate a QR code using Google Charts API
<?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