Generating QR Code with PHP

To generate QR Code there are a lot of libraries but I want to show you the easiest way to generate QR Code which is using googleapis

We start with determining the value of the height and width.

<?php
function qrCode($s, $w = 250, $h = 250){
	$u = 'https://chart.googleapis.com/chart?chs=%dx%d&cht=qr&chl=%s';
	$url = sprintf($u, $w, $h, $s);
  	return $url;
}

$qr = qrCode('phpExample', 300, 300); // 300x300
?>
<img src="<?= $qr ?>">

Result QR Code

Comments

There are no comments, make the firs comment